mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Use string literal type for script kind names
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
4
src/server/protocol.d.ts
vendored
4
src/server/protocol.d.ts
vendored
@@ -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";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user