The wiki here has a page that outlines ways to programmatically create a watched build, and suggests that createSemanticDiagnosticsBuilderProgram is likely preferable to createEmitAndSemanticDiagnosticsBuilderProgram for use cases that aren't interested in emit.
The ember-cli-typescript package uses the APIs outlined in that wiki page to integrate typechecking results into Ember CLI builds, and there've been several reports of slower re-checks after a file change from folks that have updated to typescript@4.
TypeScript Version:
- 3.9.7 (works as expected)
- 4.0.3 (exhibits slowdown)
- 4.1.0-dev.20200928 (exhibits slowdown)
Search Terms:
createWatchProgram
createSemanticDiagnosticsBuilderProgram
- 4.0 performance
Code
const ts = require('typescript');
const host = ts.createWatchCompilerHost(
'tsconfig.json',
{ noEmit: true },
ts.sys,
ts.createSemanticDiagnosticsBuilderProgram
);
ts.createWatchProgram(host);
Expected behavior:
Re-checks are at least as fast with createSemanticDiagnosticsBuilderProgram as with its counterpart that tracks emit.
Actual behavior:
In a project that takes on the order of 15s to typecheck at startup, re-checking takes less than 1s with the above invocation in 3.9, as well as in 4.0 and the most recent 4.1 nightly when using createEmitAndSemanticDiagnosticsBuilderProgram.
When using createSemanticDiagnosticsBuilderProgram in 4.0 and 4.1, though, re-checking consistently takes around 5s.
The wiki here has a page that outlines ways to programmatically create a watched build, and suggests that
createSemanticDiagnosticsBuilderProgramis likely preferable tocreateEmitAndSemanticDiagnosticsBuilderProgramfor use cases that aren't interested in emit.The
ember-cli-typescriptpackage uses the APIs outlined in that wiki page to integrate typechecking results into Ember CLI builds, and there've been several reports of slower re-checks after a file change from folks that have updated totypescript@4.TypeScript Version:
Search Terms:
createWatchProgramcreateSemanticDiagnosticsBuilderProgramCode
Expected behavior:
Re-checks are at least as fast with
createSemanticDiagnosticsBuilderProgramas with its counterpart that tracks emit.Actual behavior:
In a project that takes on the order of 15s to typecheck at startup, re-checking takes less than 1s with the above invocation in 3.9, as well as in 4.0 and the most recent 4.1 nightly when using
createEmitAndSemanticDiagnosticsBuilderProgram.When using
createSemanticDiagnosticsBuilderProgramin 4.0 and 4.1, though, re-checking consistently takes around 5s.