Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Commit

Permalink
Use builder with createProgram api
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Jan 19, 2018
1 parent 64364fe commit 93269b4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/checker/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {

import { CaseInsensitiveMap } from './fs';
import { isCaseInsensitive } from '../helpers';


const caseInsensitive = isCaseInsensitive();

if (!module.parent) {
Expand Down Expand Up @@ -95,10 +95,10 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
fileName => fileName.toLowerCase() :
(fileName => fileName);

let watchHost: ts.WatchCompilerHostOfFilesAndCompilerOptions;
let watchHost: ts.WatchCompilerHostOfFilesAndCompilerOptions<ts.SemanticDiagnosticsBuilderProgram>;
let watch: ts.WatchOfFilesAndCompilerOptions<ts.SemanticDiagnosticsBuilderProgram>;

function createWatchHost(): ts.WatchCompilerHostOfFilesAndCompilerOptions & ts.BuilderProgramHost {

function createWatchHost(): ts.WatchCompilerHostOfFilesAndCompilerOptions<ts.SemanticDiagnosticsBuilderProgram> & ts.BuilderProgramHost {
return {
rootFiles: getRootFiles(),
options: compilerOptions,
Expand All @@ -117,7 +117,9 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
watchFile,
watchDirectory,

createHash: (...args) => compiler.sys.createHash.apply(compiler.sys, args)
createProgram: compiler.createSemanticDiagnosticsBuilderProgram,

createHash: (...args) => compiler.sys.createHash.apply(compiler.sys, args)
};

function readFile(fileName: string) {
Expand All @@ -131,7 +133,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re

function createWatch(): ts.WatchOfFilesAndCompilerOptions<ts.SemanticDiagnosticsBuilderProgram> {
watchHost = createWatchHost();
return compiler.createWatchBuilderProgram(watchHost, compiler.createSemanticDiagnosticsBuilderProgram);
return compiler.createWatchProgram(watchHost);
}

function getProgram(): ts.SemanticDiagnosticsBuilderProgram {
Expand Down Expand Up @@ -385,10 +387,10 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
replyOk(seq, {
files: getProgram().getSourceFiles().map(f => f.fileName)
});
}

function isAffectedSourceFile(affected: ts.SourceFile | ts.Program): affected is ts.SourceFile {
return (affected as ts.SourceFile).kind === compiler.SyntaxKind.SourceFile;
}

function isAffectedSourceFile(affected: ts.SourceFile | ts.Program): affected is ts.SourceFile {
return (affected as ts.SourceFile).kind === compiler.SyntaxKind.SourceFile;
}

function processDiagnostics({ seq }: Diagnostics.Request) {
Expand Down

0 comments on commit 93269b4

Please sign in to comment.