Use string literal type for script kind names

This commit is contained in:
zhengbli
2016-04-19 15:17:36 -07:00
parent a2035a572e
commit cc58e2d7eb
5 changed files with 9 additions and 9 deletions

View File

@@ -496,7 +496,7 @@ namespace Harness.LanguageService {
this.client = client;
}
openFile(fileName: string, content?: string, scriptKindName?: string): void {
openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
super.openFile(fileName, content, scriptKindName);
this.client.openFile(fileName, content, scriptKindName);
}

View File

@@ -120,7 +120,7 @@ namespace ts.server {
return response;
}
openFile(fileName: string, content?: string, scriptKindName?: string): void {
openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
var args: protocol.OpenRequestArgs = { file: fileName, fileContent: content, scriptKindName };
this.processRequest(CommandNames.Open, args);
}

View File

@@ -520,9 +520,9 @@ declare namespace ts.server.protocol {
fileContent?: string;
/**
* Used to specify the script kind of the file explicitly. It could be one of the following:
* ".ts", ".js", ".tsx", ".jsx"
* "TS", "JS", "TSX", "JSX"
*/
scriptKindName?: string;
scriptKindName?: "TS" | "JS" | "TSX" | "JSX";
}
/**

View File

@@ -969,16 +969,16 @@ namespace ts.server {
const openArgs = <protocol.OpenRequestArgs>request.arguments;
let scriptKind: ScriptKind;
switch (openArgs.scriptKindName) {
case ".ts":
case "TS":
scriptKind = ScriptKind.TS;
break;
case ".js":
case "JS":
scriptKind = ScriptKind.JS;
break;
case ".tsx":
case "TSX":
scriptKind = ScriptKind.TSX;
break;
case ".jsx":
case "JSX":
scriptKind = ScriptKind.JSX;
break;
}

View File

@@ -14,6 +14,6 @@
//// var t;
//// t.
goTo.file("test.ts", /*content*/ undefined, ".js");
goTo.file("test.ts", /*content*/ undefined, "JS");
goTo.eof();
verify.completionListContains("toExponential");