A hook for fixing TypeScript issues
If you have issues in a TypeScript project that uses pnpm, this config dependency might help. It fixes packages in your dependencies by adding missing @types/
dependencies to them during installation.
pnpm add --config @pnpm/types-fixer
This will add @pnpm/types-fixer
to the configDependencies field in your pnpm-workspace.yaml
.
If you don't have a pnpmfile in your project, then add this to pnpm-workspace.yaml
:
pnpmfile: node_modules/.pnpm-config/@pnpm/types-fixer/pnpmfile.cjs
If you have a .pnpmfile.cjs
already in your project, then you can reexport the readPackage
hooks from @pnpm/types-fixer
. This should be your .pnpmfile.cjs
:
module.exports = {
hooks: {
...require('.pnpm-config/@pnpm/types-fixer/pnpmfile.cjs').hooks,
// Other hooks in your project
}
}
Alternatively, you may have other changes in your readPackage
hook:
const { readPackage: fixTypes } = require('.pnpm-config/@pnpm/types-fixer/pnpmfile.cjs').hooks
module.exports = {
hooks: {
readPackage (pkg) {
// ...
return fixTypes(pkg)
}
}
}
MIT