Repository navigation
fix(plugin): declare typescript as an optional peer dependency - #4144
Merged
kamilmysliwiec merged 1 commit intoSep 22, 2026
Merged
kamilmysliwiec merged 1 commit into
kamilmysliwiec merged 1 commit into
Conversation
4 of 5 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: #4139
The CLI plugin imports
typescriptat runtime, but@nestjs/graphqldoes not declare it anywhere in itspackage.json. Nothing tells the package manager which copy the plugin should get, so it takes whatever is 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:StringNumberEnumSo with the program on 6.0.3 and the plugin on 5.9.3, a
stringproperty reads as an enum and the generated metadata refers to a variable calledstring:The build succeeds and the app throws
ReferenceError: string is not definedwhen the schema is built.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. Verified with the reproduction from #4139 (sibling workspace package on 5.9.3, application on 6.0.3, 5.9.3 hoisted):The range is
^5.5.0 || ^6.0.0. 5.5 is the floor because the package is ESM: on 5.4 and below the named imports inplugin/utils/ast-utils.ts(import { TypeFlags, ... } from 'typescript') fail withdoes not provide an export named. Marking it optional followsts-morph, which is plugin-only in the same way. Same fix as nestjs/swagger#4134.Does this PR introduce a breaking change?
Other information
Closes #4139.