diff --git a/ts/lib/typechecking/worker/index.ts b/ts/lib/typechecking/worker/index.ts index c04c4f239..d06b10a10 100644 --- a/ts/lib/typechecking/worker/index.ts +++ b/ts/lib/typechecking/worker/index.ts @@ -138,7 +138,7 @@ export default class TypecheckWorker { private patchCompilerHostMethods( host: WatchCompilerHostOfConfigFile ) { - let { watchFile, watchDirectory, createProgram, afterProgramCreate = () => {} } = host; + let { watchFile, watchDirectory, afterProgramCreate = () => {} } = host; // Intercept tsc's `watchFile` to also invoke `mayTypecheck()` when a watched file changes host.watchFile = (path, callback, pollingInterval?) => { @@ -167,14 +167,11 @@ export default class TypecheckWorker { ); }; - // Intercept `createProgram` to invoke `willTypecheck` beforehand, as we know at this - // point that a new check is definitively happening. - host.createProgram = (...params) => { + // Intercept `afterProgramCreate` to confirm when a suspected typecheck is happening + // and schedule the new diagnostics to be emitted. + host.afterProgramCreate = (program) => { this.willTypecheck(); - return createProgram.apply(host, params); - }; - host.afterProgramCreate = (program) => { // The `afterProgramCreate` callback will be invoked synchronously when we first call // `createWatchProgram`, meaning we can enter `didTypecheck` before we're fully set up // (e.g. before `compilerOptions` has been set). We use `nextTick` to ensure that diff --git a/ts/tests/helpers/skeleton-app.ts b/ts/tests/helpers/skeleton-app.ts index 964b51dd6..7eeef974e 100644 --- a/ts/tests/helpers/skeleton-app.ts +++ b/ts/tests/helpers/skeleton-app.ts @@ -16,7 +16,7 @@ const getEmberPort = (() => { export default class SkeletonApp { port = getEmberPort(); watched: WatchedBuild | null = null; - cleanupTempDir = () => rimraf(this.root, (error) => console.error(error)); + cleanupTempDir = () => rimraf(this.root, (error) => error && console.error(error)); root = path.join(process.cwd(), `test-skeleton-app-${Math.random().toString(36).slice(2)}`); constructor() {