Is it possible to disable type checks when transpiling typescript via tsc to speed up transpiling?

1.2k Views Asked by At

TypeScript checks the entire codebase on transpiling, even if only one file has actually changed. For small projects, that is fine, yet since our codebase grew, it takes quite a long time.

During development, I want quick response time of my unit tests. The unit test should run as soon as possible.

Unfortunately, I have to wait on each run about 10-15 seconds for the unit test to even start as the the tsc takes a long time to transpile, and of that time 60%-80% is spent on checking.

These example runs are just from removing and adding a newline in one file:

yarn tsc v0.27.5
$ "/home/philipp/fancyProject/node_modules/.bin/tsc" "--watch" "--diagnostics"
Files:           511
Lines:        260611
Nodes:        898141
Identifiers:  323004
Symbols:      863060
Types:        302553
Memory used: 704680K
I/O read:      0.17s
I/O write:     0.09s
Parse time:    2.61s
Bind time:     0.95s
Check time:    7.65s
Emit time:     1.45s
Total time:   12.65s
00:35:34 - Compilation complete. Watching for file changes.


00:41:58 - File change detected. Starting incremental compilation...


Files:            511
Lines:         260612
Nodes:         898141
Identifiers:   323004
Symbols:       863060
Types:         302553
Memory used: 1085950K
I/O read:       0.00s
I/O write:      0.04s
Parse time:     0.68s
Bind time:      0.00s
Check time:    12.65s
Emit time:      1.36s
Total time:    14.69s
00:42:13 - Compilation complete. Watching for file changes.


00:42:17 - File change detected. Starting incremental compilation...


Files:            511
Lines:         260611
Nodes:         898141
Identifiers:   323004
Symbols:       863060
Types:         302553
Memory used: 1106446K
I/O read:       0.00s
I/O write:      0.12s
Parse time:     0.32s
Bind time:      0.01s
Check time:     9.28s
Emit time:      0.89s
Total time:    10.50s
00:42:27 - Compilation complete. Watching for file changes.

I wonder if there is a way to tell typescript:

Just treat everything as OK and just dump the JavaScript as quickly as possible to the disk.

I want to ensure first that my unit test pass in order to have a quick feedback loop.

And since my IDE takes care of the type checks already within the file I am currently working on, I rarely have mistake in the check of the transpiling anyway. And if there was a big issue, my unit tests should catch them.

When building the project, I would just use the classic tsc with the checks. As I have said, this is only for development and having a quick feedback loop.

1

There are 1 best solutions below

1
On
  1. Start using WebPack
  2. Add awesome-typescript-loader
  3. Set transpileOnly in setting to true

Also you can change other paramers, which can boost speed: ignoreDiagnostics, forceIsolatedModules, etc.