Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support tsc --build --noEmit #53979

Open
5 tasks done
segevfiner opened this issue Apr 24, 2023 · 7 comments
Open
5 tasks done

Support tsc --build --noEmit #53979

segevfiner opened this issue Apr 24, 2023 · 7 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@segevfiner
Copy link

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:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • 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.

@sheetalkamat
Copy link
Member

sheetalkamat commented Apr 24, 2023

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.

@segevfiner
Copy link
Author

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.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Jun 14, 2023
@thebanjomatic
Copy link

thebanjomatic commented Aug 21, 2023

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: #51164 would it be reasonable to add --noEmit as well?

@david-alpert-nl
Copy link

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'.

@Zzzen
Copy link
Contributor

Zzzen commented Aug 6, 2024

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

aentwist added a commit to aentwist/AutoAFK that referenced this issue Aug 25, 2024
Type checking is currently not evaluated for referenced files. In order
to make it evaluate, we have to use `--build`. However, this cannot be
used with `--noEmit` and so will emit compiled files unless we use the
solution tsconfig pattern.

See
- microsoft/TypeScript#53979
- vitejs/vite#15913

See also
- https://www.typescriptlang.org/docs/handbook/project-references.html#overall-structure
- vitejs/vite#17774
aentwist added a commit to aentwist/AutoAFK that referenced this issue Aug 25, 2024
Type checking is currently not evaluated for referenced files. In order
to make it evaluate, we have to use `--build`. However, this cannot be
used with `--noEmit` and so will emit compiled files unless we use the
solution tsconfig pattern.

See
- microsoft/TypeScript#53979
- vitejs/vite#15913

See also
- https://www.typescriptlang.org/docs/handbook/project-references.html#overall-structure
- vitejs/vite#17774
@proyectoramirez
Copy link

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

@aminpaks
Copy link
Contributor

aminpaks commented Oct 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

8 participants