Type helpers loose class-validator/class-transformer metadata in Yarn PnP environments
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current behavior
@nestjs/swagger
uses @nestjs/mapped-types
which uses class-validator
and class-transformer
(if they’re present) to inherit validation/transformer metadata.
@nestjs/swagger
brings@nestjs/mapped-types
as dependency.@nestjs/mapped-types
requiresclass-validator
andclass-transformer
as optional peer dependencies.@nestjs/swagger
doesn’t provideclass-validator
andclass-transformer
.@nestjs/swagger
->@nestjs/mapped-types
checks whetherclass-validator
andclass-transformer
are present, sees that they aren’t and doesn’t inherit metadata (ref).
Yarn PnP doesn’t allow implicit requirements which may cause undefined behaviour. It means Yarn PnP expects from @nestjs/swagger
to satisfy @nestjs/mapped-types
peer/optional dependencies since it’s the direct dependency.
Minimum reproduction code
https://gist.github.com/khmm12/c2a4bdab7dfa82d33f06c45a768ad6d7
Steps to reproduce
No response
Expected behavior
I see 2 possible solutions:
@nestjs/swagger
should specify@nestjs/mapped-types
as peer dependency instead of dependency.@nestjs/swagger
should specifyclass-validator
andclass-transformer
as optional dependencies.
Package version
6.13
NestJS version
No response
Node.js version
No response
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Inherit peer dependency ranges from your own ... - GitHub
Type helpers loose class-validator/class-transformer metadata in Yarn PnP environments nestjs/swagger#2169.
Read more >Plug'n'Play | Yarn - Package Manager
To address this problem, Yarn ships with a "loose" mode which will cause the PnP linker to work in tandem with the node-modules...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for chiming in & clarifying @arcanis, and for a thorough discussion @khmm12. Appreciate your time!
Since it doesn’t hurt to explicitly add the inner package’s peer dependencies, let’s just add them in to be compatible with Yarn PnP. Would you like to create a PR @khmm12? Let me know if you’re busy and if so I’ll take care of this myself!
@kamilmysliwiec I’ll create PRs for @nestjs/swagger and @nestjs/graphql 👍