microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.29k stars 12.39k forks source link

Allow transformers to run without type-checking #41986

Open pauldraper opened 3 years ago

pauldraper commented 3 years ago

Search Terms

transformer, type check, transpileModule

Suggestion

Run transformers, but skip type checking.

Use Cases

The majority of compile times are type checking.

Some projects (e.g. Angular stylesheet integration) require transformers to run.

I would like to skip type checking, ala transpileModule, but still run the transformer.

https://github.com/angular/angular-cli/issues/19587

Examples

Checklist

My suggestion meets these guidelines:

hardfist commented 3 years ago

We also want this feature, for large monorepo project(40+ package), tsc build speed is too slow(may cost 10+ mins to compile whole project), even thou we could speed up build speed using esbuild, we still need to generate dts(which esbuild does not support), so we want generate dts without doing typecheck(which costs most of the time), we also use transpileModule on serve side to transform es6 code to es5, which typecheck slows the build speed and makes no sense on server side.

Kingwl commented 3 years ago

It's not possible yet. The transformer has some dependency on the type checker.

eg: EmitResolver.createTypeOfDeclaration

We have:

let a = 1

transform to:

declare let a: number;

Which means It's not pure syntax transform. We have to check the type to create the type annotation number.

pauldraper commented 2 years ago

or large monorepo project(40+ package), tsc build speed is too slow

transpileModule tis the only way.

Side note: Kind of odd you can't do it via CLI.