Skip to content

fix(plugins): add ts-nocheck directive to generated metadata file#3378

Closed
maruthang wants to merge 1 commit intonestjs:masterfrom
maruthang:fix/issue-3364-metadata-nodenext
Closed

fix(plugins): add ts-nocheck directive to generated metadata file#3378
maruthang wants to merge 1 commit intonestjs:masterfrom
maruthang:fix/issue-3364-metadata-nodenext

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

The PluginMetadataGenerator produces a metadata.ts file containing dynamic imports without file extensions. When a project uses nodenext or node16 module 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.ts file now includes a // @ts-nocheck directive immediately after the existing /* eslint-disable */ comment. This suppresses TypeScript errors from the extensionless dynamic imports, allowing projects with nodenext module 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?

[ ] Yes
[x] No

Other information

Files changed:

  • lib/compiler/plugins/plugin-metadata-printer.ts: Added // @ts-nocheck to the generated file prefix string
  • test/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

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
@kamilmysliwiec
Copy link
Copy Markdown
Member

#3365 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants