NestJS Swagger Plugin when used with SWC references undeclared variable. #12459
Closed
3 of 15 tasks
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
When
@nestjs/swagger
CLI plugin is used alongside SWC, it generates output in the metadata.ts from thePluginMetadataGenerator
that includes undeclared variables. These variables inside the metadata.ts trigger failures when type checking, also during runtime if the metadata is attempted to be used somewhere likeloadPluginMetadata
.In my reproduction I have
HelloClass
andHelloClassSeperate
demonstrating that this bug is only present when the class exists in the same file as the DTO.metadata.ts -> Problem area:
{ required: true, type: () => [HelloClass] }
Minimum reproduction code
https://github.com/evanwhitten/reproduce-cli-swagger-reference
Steps to reproduce
nest start -b swc --type-check
-> view error from invalid metadata.ts generatedExpected behavior
Expected to have Swagger definitions generated the same as when running the app without SWC.
Without SWC
With SWC
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
@nestjs/swagger
NestJS version
10.2.6
Packages versions
Node.js version
v18.16.1
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: