Skip to content

Commit

Permalink
Use createProgram api of the watch compiler host
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Jan 19, 2018
1 parent b2d6c2a commit 42e04a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function getTypeScriptInstance(
instance.watchHost.updateRootFileNames();
}
if (instance.watchOfFilesAndCompilerOptions) {
instance.program = instance.watchOfFilesAndCompilerOptions.getProgram();
instance.program = instance.watchOfFilesAndCompilerOptions.getProgram().getProgram();
}
}
return { instance: instances[loaderOptions.instance] };
Expand Down Expand Up @@ -168,7 +168,7 @@ function successfulTypeScriptInstance(
// If there is api available for watch, use it instead of language service
const watchHost = makeWatchHost(scriptRegex, log, loader, instance, loaderOptions.appendTsSuffixTo, loaderOptions.appendTsxSuffixTo);
instance.watchOfFilesAndCompilerOptions = compiler.createWatchProgram(watchHost);
instance.program = instance.watchOfFilesAndCompilerOptions.getProgram();
instance.program = instance.watchOfFilesAndCompilerOptions.getProgram().getProgram();
}
else {
const servicesHost = makeServicesHost(scriptRegex, log, loader, instance, loaderOptions.appendTsSuffixTo, loaderOptions.appendTsxSuffixTo);
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export interface ModuleResolutionHost {
readFile(fileName: string, encoding?: string | undefined): string | undefined;
}

export interface WatchHost extends typescript.WatchCompilerHostOfFilesAndCompilerOptions {
export interface WatchHost extends typescript.WatchCompilerHostOfFilesAndCompilerOptions<typescript.BuilderProgram> {
invokeFileWatcher(fileName: string, eventKind: typescript.FileWatcherEventKind): void;
invokeDirectoryWatcher(directory: string, fileAddedOrRemoved: string): void;
updateRootFileNames(): void;
Expand Down Expand Up @@ -242,7 +242,7 @@ export interface TSInstance {

otherFiles: TSFiles;
watchHost?: WatchHost;
watchOfFilesAndCompilerOptions?: typescript.WatchOfFilesAndCompilerOptions<typescript.Program>;
watchOfFilesAndCompilerOptions?: typescript.WatchOfFilesAndCompilerOptions<typescript.BuilderProgram>;
program?: typescript.Program;
changedFilesList?: boolean;
}
Expand Down
3 changes: 2 additions & 1 deletion src/servicesHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ export function makeWatchHost(
if (instance.watchOfFilesAndCompilerOptions) {
instance.watchOfFilesAndCompilerOptions.updateRootFileNames(getRootFileNames());
}
}
},
createProgram: compiler.createAbstractBuilder
};
return watchHost;

Expand Down

0 comments on commit 42e04a5

Please sign in to comment.