Skip to content

fix(typecheck-worker): avoid false-positive willTypechecks on Linux #1198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions ts/lib/typechecking/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class TypecheckWorker {
private patchCompilerHostMethods(
host: WatchCompilerHostOfConfigFile<SemanticDiagnosticsBuilderProgram>
) {
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?) => {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ts/tests/helpers/skeleton-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down