Skip to content

tsc compilation slow on moderate sized project #37635

Closed
@rightisleft

Description

@rightisleft

TypeScript Version: 3.9.0-dev.20200326

Search Terms:

tsc slow compilation, tsc memory, tsc slow Program time, tsc Program time

Code

I'm trying to debug why my typescript compiler is taking 9-13 seconds to recompile. This impacts ts-node and development drastically.

typescript version: ^3.X.X

tsconfig.json:

{
  "compilerOptions": {
    "extendedDiagnostics": true,
    "target": "es6",
    "lib": ["es2017"],
    "module": "commonjs",
    "emitDeclarationOnly": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "incremental": true,
    "noResolve": false,
    "noEmitOnError": false,
    "noImplicitAny": true,
    "declaration": true,
    "sourceMap": true,
    "outDir": "dist/",
    "moduleResolution": "node",
    "skipLibCheck": true
  },
  "include": [
    "src/**/*.ts",
    "test/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}
npx tsc --listFiles --generateCpuProfile profile

Files: 732
Lines: 364288
Nodes: 1133413
Identifiers: 417612
Symbols: 236577
Types: 76
Instantiations: 0
Memory used: 330244K
Assignability cache size: 0
Identity cache size: 0
Subtype cache size: 0
Strict subtype cache size: 0
I/O Read time: 2.51s
Parse time: 3.77s
ResolveTypeReference time: 0.33s
ResolveModule time: 2.91s
Program time: 9.86s
Bind time: 1.39s
Total time: 11.25s

File List Here: https://pastebin.com/zX7TpM2x

Generated CPU Profile Here: https://gist.github.com/rightisleft/d3c77fe2c643ba4c7832a94209f53ef2

Expected behavior:

This is a mid sized project, it should have a 1-3 second compile time

Actual behavior:

Compile takes anywhere from 9-14 seconds per line change

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions