The inferred type of 'parse' cannot be named without a reference to...
Hey! I am getting this error while trying to create an interaction handler:
The inferred type of 'parse' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@sapphire/result'. This is likely not portable. A type annotation is necessary.
This is my code:
Solution:Jump to solution
yeah so basically pnpm doesn't patch typescript to ensure that it considers the folder where it dumps the non hoisted files for the typescript server/compiler. It's a major flaw in pnpm. If you look for example at Yarn which also has a PnP mode (opt in), they do patch TypeScript for this very reason. It's extremely dumb to think that you're non compliant solution will just work OOTB with the whole ecosystem and I honestly blame pnpm devs for this very much. Wouldn't be surprised if they have various open issues on the topic, have never checked.
Basically any installed package that then module augments another installed package (transitive or not), will not work with pnpm. In our case,
@sapphire/framework
has a transitive dependency on @sapphire/pieces
and also module augments @sapphire/pieces
, and discord.js
for that matter....4 Replies
Adding these imports to the top of the file makes the error dissapear:
import { Result, None, Option } from '@sapphire/framework';
Makes no sense though, as I don't even use themSeeing as you’re using pnpm, have you configured the hoisting pattern (that should be mentioned in the docs but I can’t find anymore)?
I did not, that should be the issue. I switched back to npm as I wasn't able to fix it. Thank you 🙂
Solution
yeah so basically pnpm doesn't patch typescript to ensure that it considers the folder where it dumps the non hoisted files for the typescript server/compiler. It's a major flaw in pnpm. If you look for example at Yarn which also has a PnP mode (opt in), they do patch TypeScript for this very reason. It's extremely dumb to think that you're non compliant solution will just work OOTB with the whole ecosystem and I honestly blame pnpm devs for this very much. Wouldn't be surprised if they have various open issues on the topic, have never checked.
Basically any installed package that then module augments another installed package (transitive or not), will not work with pnpm. In our case,
@sapphire/framework
has a transitive dependency on @sapphire/pieces
and also module augments @sapphire/pieces
, and discord.js
for that matter.