Skip to content

Commit e36df0d

Browse files
committed
add return types
1 parent 6a05d4b commit e36df0d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/ts-autocomplete/src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function getVirtualLanguageService(): [
1515
allowJs: true,
1616
};
1717

18-
const updateCode = (newDef: Record<TypeFilename, string>) => {
18+
const updateCode = (newDef: Record<TypeFilename, string>): void => {
1919
for (const [key, value] of Object.entries(newDef)) {
2020
codeHolder[key] = value;
2121
versions[key] = (versions[key] ?? 1) + 1;
@@ -54,7 +54,13 @@ function getVirtualLanguageService(): [
5454
];
5555
}
5656

57-
function mapCompletions(completions: ts.CompletionInfo) {
57+
type AutoCompletion = {
58+
name: string;
59+
kind: ts.ScriptElementKind;
60+
type: string;
61+
};
62+
63+
function mapCompletions(completions: ts.CompletionInfo): AutoCompletion[] {
5864
return completions.entries.map((entry) => {
5965
const declarations = entry.symbol?.getDeclarations();
6066
let type = 'any';
@@ -79,7 +85,7 @@ export default class Autocompleter {
7985
[this.languageService, this.updateCode] = getVirtualLanguageService();
8086
}
8187

82-
autocomplete(code: string, position?: number) {
88+
autocomplete(code: string, position?: number): AutoCompletion[] {
8389
if (typeof position === 'undefined') {
8490
position = code.length;
8591
}

0 commit comments

Comments
 (0)