TypeScript: tsc: TS5053: Option 'noEmit' cannot be specified with option 'composite'
TypeScript Version: 3.9.0-dev.20200220 (broken in 3.8.2)
Search Terms: TS5053: Option ‘noEmit’ cannot be specified with option ‘composite’
Code
{
"compilerOptions": {
"composite": true
}
}
Expected behavior:
Run a type-check with no errors, as in 3.7 and previous versions.
Actual behavior:
# npx tsc --noEmit
tsconfig.json:3:5 - error TS5053: Option 'noEmit' cannot be specified with option 'composite'.
3 "composite": true,
~~~~~~~~~~~
Found 1 error.
Additional comments:
We use composite in our tsconfig.json to ensure the output directory structure is always the same.
We also use --noEmit in our CI pipelines to ensure type-checking before building a Docker image.
Is the --noEmit the best way to do type-checking without the overhead of running an entire build (with output files) or this breaking change should really be reverted?
Related Issues:
#36588 - attempt to remove the composite from tsconfig.json and use as CLI flag when building project
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 28
- Comments: 21 (10 by maintainers)
Commits related to this issue
- fix: Option 'noEmit' cannot be specified with option 'composite' https://github.com/microsoft/TypeScript/issues/36917#issuecomment-592136968 — committed to LeetCode-OpenSource/themes by runjuu 4 years ago
- Add --composite false to "typecheck:api" npm command TypeScript incremental build seems to be a problem for projects using Babel, like Next.js apps: "error TS5053: Option 'noEmit' cannot be specifie... — committed to iquabius/olimat by iquabius 4 years ago
- Update dependency typescript to v3.9.5 (#278) * Update dependency typescript to v3.9.5 * Update dependency typescript to v3.9.5 * Fix name clashes in resolvers-types.ts with a hack I modifie... — committed to iquabius/olimat by renovate[bot] 4 years ago
I understand that
compositeneeds metadata to work properly, but now there’s no way to run a simple type-check within the CLI without actually building something.compositewas released in TypeScript 3.0 and worked withnoEmituntil 3.8.I’m really not against that change, but as #36588 blocks us from removing
compositefromtsconfig.jsonand using it on compile-time, there’s no way to run a type-check without build artifacts.For someone who found this thread after upgrading to TypeScript 3.8 and after passing
--incremental falsetogether with--noEmitbut gets another errorTS5069: Option 'tsBuildInfoFile' cannot be specified without specifying option 'incremental' or option 'composite'.the solution is passing--tsBuildInfoFile nullas well (yeah,null). This ain’t intuitive, so it might be helpful.Eject from create-react-app.
I have the same problem but with
noEmitandincremental. Is there any other way to run a type-check without building anything?I’ve the same problem in a mono repo. so that I can continue to work, I created a tsconfig.test.json
{ "extends": "./tsconfig.json", "compilerOptions": { "composite": false } }to use it with --noEmit:
"lint": "tsc -p tsconfig.test.json --noEmit && eslint \"**/*.{ts,tsx}\" --quiet --fix",So I can lint my packages at least
Closing this since we are now allowing passing
--composite falsefrom the command lineThe problem is that they can not be unset in command line. During development, it’s good to have them, but for checking during commit, it’d be better to do something like
tsc --noEmit --composite false. But right nowtscdoesn’t allow to have it in command line, so we basically need to have separate config files. See https://github.com/microsoft/TypeScript/issues/36588@weswigham Sorry, to clarify: we have
incrementalset in ourtsconfig, which until now we’ve used for our production builds, local environment builds and type-checks on commit. For the type-check on commit we’ve passed--noEmitas a CLI argument. As far as I can tell what we have to do now is add a separatetsconfigfor type-checking as @dotupNET suggested.So I’m wondering if there’s a way to avoid having two config files.
I think allowing composite to be set to false (not true) seems like a better solution here. Looking into this.
@hollg you could pass
--incremental false --noEmitrather than just--noEmitfor the CI pass, no?compositerequires declaration output to actually do incremental work - useemitDeclarationsOnlyinstead ofnoEmit.We have a similar issue. We have a monorepo and use path references, which requires
composite: true. We used to use--noEmitto perform type-checking on commit hook, but now it doesn’t seem to be possible without actually building files.