fix(plugins): add ts-nocheck directive to generated metadata file#3378
Closed
maruthang wants to merge 1 commit intonestjs:masterfrom
Closed
fix(plugins): add ts-nocheck directive to generated metadata file#3378maruthang wants to merge 1 commit intonestjs:masterfrom
maruthang wants to merge 1 commit intonestjs:masterfrom
Conversation
The PluginMetadataGenerator produces dynamic imports without file extensions in the generated metadata file. When the project uses nodenext module resolution, these extensionless imports cause TypeScript errors. Adding // @ts-nocheck to the generated file suppresses these errors since the metadata file is auto-generated and the imports work correctly at runtime. Closes nestjs#3364
Member
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?
The
PluginMetadataGeneratorproduces ametadata.tsfile containing dynamic imports without file extensions. When a project usesnodenextornode16module resolution, TypeScript raises errors on these extensionless imports because strict ESM resolution requires explicit file extensions. This prevents successful compilation even though the imports work correctly at runtime.Issue Number: #3364
What is the new behavior?
The generated
metadata.tsfile now includes a// @ts-nocheckdirective immediately after the existing/* eslint-disable */comment. This suppresses TypeScript errors from the extensionless dynamic imports, allowing projects withnodenextmodule resolution to compile without errors. Since the metadata file is auto-generated and the imports resolve correctly at runtime, suppressing type checking on this file is safe and appropriate.Does this PR introduce a breaking change?
Other information
Files changed:
lib/compiler/plugins/plugin-metadata-printer.ts: Added// @ts-nocheckto the generated file prefix stringtest/lib/compiler/plugins/plugin-metadata-printer.spec.ts: New test file with 4 tests verifying the printer output includes the directive and produces correct metadata structure