Skip to content

Commit 520979d

Browse files
Make getLocalizedDiagnosticMessages and getCancellationToken optional
1 parent 1fab80f commit 520979d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/harness/harness.ts

-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,6 @@ module Harness {
575575

576576
return {
577577
getCurrentDirectory: ts.sys.getCurrentDirectory,
578-
getCancellationToken: (): any => undefined,
579578
getSourceFile: (fn, languageVersion) => {
580579
if (Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(fn))) {
581580
return filemap[getCanonicalFileName(fn)];

src/services/services.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,8 @@ module ts {
875875
getScriptVersion(fileName: string): string;
876876
getScriptIsOpen(fileName: string): boolean;
877877
getScriptSnapshot(fileName: string): IScriptSnapshot;
878-
getLocalizedDiagnosticMessages(): any;
879-
getCancellationToken(): CancellationToken;
878+
getLocalizedDiagnosticMessages?(): any;
879+
getCancellationToken?(): CancellationToken;
880880
getCurrentDirectory(): string;
881881
getDefaultLibFilename(options: CompilerOptions): string;
882882
}
@@ -2395,12 +2395,12 @@ module ts {
23952395
var useCaseSensitivefilenames = false;
23962396
var sourceFilesByName: Map<SourceFile> = {};
23972397
var documentRegistry = documentRegistry;
2398-
var cancellationToken = new CancellationTokenObject(host.getCancellationToken());
2398+
var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken());
23992399
var activeCompletionSession: CompletionSession; // The current active completion session, used to get the completion entry details
24002400
var writer: (filename: string, data: string, writeByteOrderMark: boolean) => void = undefined;
24012401

24022402
// Check if the localized messages json is set, otherwise query the host for it
2403-
if (!localizedDiagnosticMessages) {
2403+
if (!localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) {
24042404
localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
24052405
}
24062406

0 commit comments

Comments
 (0)