Skip to content

Commit 264ce6d

Browse files
jriekenscottlu
authored andcommitted
make host implement getScriptKind, #203
1 parent c758171 commit 264ce6d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/worker.ts

+13
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ export class TypeScriptWorker implements ts.LanguageServiceHost {
9393
};
9494
}
9595

96+
getScriptKind?(fileName: string): ts.ScriptKind {
97+
const suffix = fileName.substr(fileName.lastIndexOf('.') + 1);
98+
switch (suffix) {
99+
case 'ts': return ts.ScriptKind.TS;
100+
case 'tsx': return ts.ScriptKind.TSX;
101+
case 'js': return ts.ScriptKind.JS;
102+
case 'jsx': return ts.ScriptKind.JSX;
103+
default: return this.getCompilationSettings().allowJs
104+
? ts.ScriptKind.JS
105+
: ts.ScriptKind.TS;
106+
}
107+
}
108+
96109
getCurrentDirectory(): string {
97110
return '';
98111
}

0 commit comments

Comments
 (0)