Browse Source

make host implement getScriptKind, #203

Johannes Rieken 8 years ago
parent
commit
9b5c885b40
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/worker.ts

+ 13 - 0
src/worker.ts

@@ -93,6 +93,19 @@ export class TypeScriptWorker implements ts.LanguageServiceHost {
 		};
 	}
 
+	getScriptKind?(fileName: string): ts.ScriptKind {
+		const suffix = fileName.substr(fileName.lastIndexOf('.') + 1);
+		switch (suffix) {
+			case 'ts': return ts.ScriptKind.TS;
+			case 'tsx': return ts.ScriptKind.TSX;
+			case 'js': return ts.ScriptKind.JS;
+			case 'jsx': return ts.ScriptKind.JSX;
+			default: return this.getCompilationSettings().allowJs
+				? ts.ScriptKind.JS
+				: ts.ScriptKind.TS;
+		}
+	}
+
 	getCurrentDirectory(): string {
 		return '';
 	}