TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Support `tsc --build --noEmit`

Open segevfiner opened this issue 2 years ago • 7 comments

Suggestion

🔍 Search Terms

tsc --build --noEmit build noEmit

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

✅ Viability Checklist

My suggestion meets these guidelines:

  • [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [x] This wouldn't change the runtime behavior of existing JavaScript code
  • [x] This could be implemented without emitting different JS based on the types of the expressions
  • [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • [x] This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Allow tsc --build --noEmit, the relevant types can be emitted to the tsbuildinfo for incremental building. This is very useful to allow type checking only for projects using project references and working with a bundler. e.g. A create-vue project, which currently has to resort to hackery such as vue-tsc --noEmit -p tsconfig.vitest.json --composite false which is not as accurate as type checking each project individually.

📃 Motivating Example

tsc --build --noEmit is now supported, allowing to only run type checking for projects using project references that don't also build types using tsc.

💻 Use Cases

Type checking only, for projects using other build tools than tsc but still using project references for each of configuration.

segevfiner avatar Apr 24 '23 08:04 segevfiner

tsc --build --noEmit is supported unless a project references another project which would make it difficult to support since its depending on d.ts output file from the referenced project.

sheetalkamat avatar Apr 24 '23 16:04 sheetalkamat

Note that referenced projects were not allowed to specify noEmit in TS<5, but they are allowed now, although the behavior in terms of type checking is unclear, seems like it skips them or something of that sort.

segevfiner avatar Apr 24 '23 17:04 segevfiner

I encountered this problem as well recently. You can specify noEmit: true in the tsconfig.js, but you can't pass it via the command-line. Support for --emitDeclarationOnly was added in this PR: https://github.com/microsoft/TypeScript/issues/51164 would it be reasonable to add --noEmit as well?

thebanjomatic avatar Aug 21 '23 03:08 thebanjomatic

I got here because I am attempting to run tsc --noEmit for type checking since my build tooling (vite) explicitly transpiles only and does not validate type consistency.

I find that tsc --noEmit does what I want but emits no progress while it's running. when I tried to add --verbose it says that the progress update is only supported with --build but that --build and --noEmit are not permitted together

tsc --verbose --noemit 
error TS5093: Compiler option '--verbose' may only be used with '--build'.
tsc --build --verbose --noemit
error TS5094: Compiler option '--noemit' may not be used with '--build'.

david-alpert-nl avatar Mar 25 '24 19:03 david-alpert-nl

We are handling a sizable project where approximately 30% of the time is spent on transform and emit tasks. This duration could be decreased if this functionality is incorporated.

Projects in scope:                        100
Projects built:                            95
Aggregate Files:                       415465
Aggregate Lines of Library:           3727607
Aggregate Lines of Definitions:      25912137
Aggregate Lines of TypeScript:        2453924
Aggregate Lines of JavaScript:            844
Aggregate Lines of JSON:               111484
Aggregate Lines of Other:                   0
Aggregate Identifiers:               37850747
Aggregate Symbols:                   33949727
Aggregate Types:                      3646787
Aggregate Instantiations:            14245043
Aggregate Memory used:               3977596K
Aggregate Assignability cache size:   1965511
Aggregate Identity cache size:          96331
Aggregate Subtype cache size:          121867
Aggregate Strict subtype cache size:   116815
Aggregate I/O Read time:                1.57s
Aggregate Parse time:                  16.50s
Aggregate ResolveModule time:          14.52s
Aggregate ResolveTypeReference time:    0.51s
Aggregate ResolveLibrary time:          0.24s
Aggregate Program time:                56.92s
Aggregate Bind time:                    8.03s
Aggregate Check time:                 227.75s
Aggregate transformTime time:          33.99s
Aggregate commentTime time:             2.28s
Aggregate Source Map time:              2.16s
Aggregate printTime time:              59.12s
Aggregate Emit time:                   59.28s
Aggregate I/O Write time:               4.87s
Config file parsing time:               0.64s
Up-to-date check time:                  0.00s
Build time:                           371.55s

Zzzen avatar Aug 06 '24 03:08 Zzzen

I am equally finding a need for this option. I am working on a large codebase with project references, and I am having issues related to this. We have had refactors that cause typechecking issues due to old dist files being left behind.

This could be solved with --build --noEmit, since we only need the typechecking signal from tsc. The files are otherwise all bundled via webpack

proyectoramirez avatar Oct 04 '24 17:10 proyectoramirez

We're looking for something similar but for type checking a single composite project without generating any output (maybe except for tsconfig.tsbuildinfo). Currently a composite project can't turn off declarations.

aminpaks avatar Oct 19 '24 21:10 aminpaks