fix: declare typescript as an optional peer dependency - #4134
Merged
kamilmysliwiec merged 1 commit intoSep 22, 2026
Merged
Conversation
4 tasks
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #4132
The CLI plugin imports
typescriptat runtime, but the package lists it only as a devDependency. Nothing tells the package manager which copy the plugin should get, so it takes whatever happens to be reachable from its install location. In a pnpm workspace with more than one TypeScript around, that can be a different version than the one@nestjs/clicompiles with.The plugin inspects the compiler's types but compares
type.flagsagainst theTypeFlagsof its own copy, and TypeScript 6 renumbered them:StringNumberEnumBigIntSo with the program on 6.0.3 and the plugin on 5.9.3, a
stringreads as an enum and anumberreads as a bigint:The build succeeds and the app throws
ReferenceError: string is not definedas soon as the DTO is loaded. The same source with both sides on 6.0.3 emitstype: () => Stringandtype: () => Number.What is the new behavior?
typescriptis declared as an optional peer dependency, so the package manager resolves it from the application instead of leaving it to hoisting. In a pnpm workspace the plugin now gets the application's copy linked into its ownnode_modules:The range is
^5.5.0 || ^6.0.0. 5.5 is the floor because the package is ESM: on 5.4 and belowimport { TypeFlags } from 'typescript'fails withdoes not provide an export named. Marking it optional followsts-morphin@nestjs/graphql, which is plugin-only in the same way.@nestjs/graphqlhas the same problem and is reported in nestjs/graphql#4139.Does this PR introduce a breaking change?
Other information
Closes #4132.