Skip to content

Commit 2aa8f05

Browse files
committed
Fix to test harness and addressing CR comments
1 parent a71fa45 commit 2aa8f05

5 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ namespace ts {
536536

537537
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
538538

539-
const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0 || scriptKind == ScriptKind.Js;
539+
const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0 || scriptKind == ScriptKind.JS;
540540

541541
initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor);
542542

src/compiler/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,10 +2462,10 @@ namespace ts {
24622462

24632463
export const enum ScriptKind {
24642464
Unknown = 0,
2465-
Js = 1,
2466-
Jsx = 2,
2467-
Ts = 3,
2468-
Tsx = 4
2465+
JS = 1,
2466+
JSX = 2,
2467+
TS = 3,
2468+
TSX = 4
24692469
}
24702470

24712471
export const enum ScriptTarget {

src/harness/harnessLanguageService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ namespace Harness.LanguageService {
183183
const script = this.getScriptInfo(fileName);
184184
return script ? new ScriptSnapshot(script) : undefined;
185185
}
186-
getScriptKind(fileName: string): ScriptKind { return ScriptKind.Unknown; }
186+
getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; }
187187
getScriptVersion(fileName: string): string {
188188
const script = this.getScriptInfo(fileName);
189189
return script ? script.version.toString() : undefined;
@@ -254,7 +254,7 @@ namespace Harness.LanguageService {
254254
const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
255255
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
256256
}
257-
getScriptKind(fileName: string): ScriptKind { return this.nativeHost.getScriptKind(fileName); }
257+
getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); }
258258
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
259259
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
260260

src/services/services.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ namespace ts {
10191019
getNewLine?(): string;
10201020
getProjectVersion?(): string;
10211021
getScriptFileNames(): string[];
1022-
getScriptKind(fileName: string): ScriptKind;
1022+
getScriptKind?(fileName: string): ScriptKind;
10231023
getScriptVersion(fileName: string): string;
10241024
getScriptSnapshot(fileName: string): IScriptSnapshot;
10251025
getLocalizedDiagnosticMessages?(): any;
@@ -1750,7 +1750,7 @@ namespace ts {
17501750

17511751
private createEntry(fileName: string, path: Path) {
17521752
let entry: HostFileInformation;
1753-
const scriptKind = this.host.getScriptKind(fileName);
1753+
const scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : ScriptKind.Unknown;
17541754
const scriptSnapshot = this.host.getScriptSnapshot(fileName);
17551755
if (scriptSnapshot) {
17561756
entry = {
@@ -1823,7 +1823,7 @@ namespace ts {
18231823
throw new Error("Could not find file: '" + fileName + "'.");
18241824
}
18251825

1826-
const scriptKind = this.host.getScriptKind(fileName);
1826+
const scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : ScriptKind.Unknown;
18271827
const version = this.host.getScriptVersion(fileName);
18281828
let sourceFile: SourceFile;
18291829

src/services/shims.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace ts {
5555

5656
/** Returns a JSON-encoded value of the type: string[] */
5757
getScriptFileNames(): string;
58-
getScriptKind(fileName: string): ScriptKind;
58+
getScriptKind?(fileName: string): ScriptKind;
5959
getScriptVersion(fileName: string): string;
6060
getScriptSnapshot(fileName: string): ScriptSnapshotShim;
6161
getLocalizedDiagnosticMessages(): string;
@@ -350,7 +350,8 @@ namespace ts {
350350
public getScriptKind(fileName: string): ScriptKind {
351351
try {
352352
return this.shimHost.getScriptKind(fileName);
353-
} catch (e) {
353+
}
354+
catch (e) {
354355
return ScriptKind.Unknown;
355356
}
356357
}

0 commit comments

Comments
 (0)