Skip to content

Commit cc58e2d

Browse files
committed
Use string literal type for script kind names
1 parent a2035a5 commit cc58e2d

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/harness/harnessLanguageService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ namespace Harness.LanguageService {
496496
this.client = client;
497497
}
498498

499-
openFile(fileName: string, content?: string, scriptKindName?: string): void {
499+
openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
500500
super.openFile(fileName, content, scriptKindName);
501501
this.client.openFile(fileName, content, scriptKindName);
502502
}

src/server/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace ts.server {
120120
return response;
121121
}
122122

123-
openFile(fileName: string, content?: string, scriptKindName?: string): void {
123+
openFile(fileName: string, content?: string, scriptKindName?: "TS" | "JS" | "TSX" | "JSX"): void {
124124
var args: protocol.OpenRequestArgs = { file: fileName, fileContent: content, scriptKindName };
125125
this.processRequest(CommandNames.Open, args);
126126
}

src/server/protocol.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ declare namespace ts.server.protocol {
520520
fileContent?: string;
521521
/**
522522
* Used to specify the script kind of the file explicitly. It could be one of the following:
523-
* ".ts", ".js", ".tsx", ".jsx"
523+
* "TS", "JS", "TSX", "JSX"
524524
*/
525-
scriptKindName?: string;
525+
scriptKindName?: "TS" | "JS" | "TSX" | "JSX";
526526
}
527527

528528
/**

src/server/session.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -969,16 +969,16 @@ namespace ts.server {
969969
const openArgs = <protocol.OpenRequestArgs>request.arguments;
970970
let scriptKind: ScriptKind;
971971
switch (openArgs.scriptKindName) {
972-
case ".ts":
972+
case "TS":
973973
scriptKind = ScriptKind.TS;
974974
break;
975-
case ".js":
975+
case "JS":
976976
scriptKind = ScriptKind.JS;
977977
break;
978-
case ".tsx":
978+
case "TSX":
979979
scriptKind = ScriptKind.TSX;
980980
break;
981-
case ".jsx":
981+
case "JSX":
982982
scriptKind = ScriptKind.JSX;
983983
break;
984984
}

tests/cases/fourslash/server/openFileWithSyntaxKind.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
//// var t;
1515
//// t.
1616

17-
goTo.file("test.ts", /*content*/ undefined, ".js");
17+
goTo.file("test.ts", /*content*/ undefined, "JS");
1818
goTo.eof();
1919
verify.completionListContains("toExponential");

0 commit comments

Comments
 (0)