fastify-swagger: issue when using yarn v2 pnp mode compiling with typescript - `fastify-swagger` can't access `fastify` package
Info about pnp: https://next.yarnpkg.com/features/pnp
🐛 Bug Report
yarn run build stdout:
.yarn/cache/fastify-swagger-npm-2.5.0-ec8013378d-2.zip/node_modules/fastify-swagger/index.d.ts(2,26): error TS2307: Cannot find module 'fastify'.
To Reproduce
Steps to reproduce the behavior:
// package.json
{
"dependencies": {
"fastify": "^2.11.0",
"fastify-swagger": "^2.5.0"
}
}
// index.ts
import fastify from 'fastify'
import fastifySwagger from 'fastify-swagger'
# build the source code
$ tsc
Fix
To fix this fastify
should be peer dependency of fastify-swagger
Will make PR
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (16 by maintainers)
I’m the wrong person to ask about this. My stance is “no typescript and no yarn”.
I agree with @jsumners that
peerDependencies
are a pain with npm - I thinkyarn
andpnpm
use them well. Morever, npm plans to change them again in v7. I’m not sure usingpeerDependencies
is is a viable strategy.Could we add something yarn-specific somewhere to just instruct on how to deal with this? From my point of view, a totally valid setup end up not working because of incompatible choices of the yarn, TS and npm teams.
I think that adding fastify as peer dep is correct regardless this security (?) check from pnp as peer depth has been added for this purpose for what I know.
I can do the change to all the fastify’s plugins in the org tomorrow if we all agree