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:
import { InteractionHandler, InteractionHandlerTypes, PieceContext } from "@sapphire/framework";
import { ModalSubmitInteraction } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

export class EmbedEditModal extends InteractionHandler {
public constructor(ctx: PieceContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.ModalSubmit
})
}

public override parse(interaction: ModalSubmitInteraction) {
return interaction.customId.startsWith('embed-edit') ? this.some() : this.none()
}
}
import { InteractionHandler, InteractionHandlerTypes, PieceContext } from "@sapphire/framework";
import { ModalSubmitInteraction } from "discord.js";
import { ApplyOptions } from "@sapphire/decorators";

export class EmbedEditModal extends InteractionHandler {
public constructor(ctx: PieceContext, options: InteractionHandler.Options) {
super(ctx, {
...options,
interactionHandlerType: InteractionHandlerTypes.ModalSubmit
})
}

public override parse(interaction: ModalSubmitInteraction) {
return interaction.customId.startsWith('embed-edit') ? this.some() : this.none()
}
}
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....
Jump to solution
4 Replies
yibuh
yibuhOP14mo ago
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 them
Favna
Favna14mo ago
Seeing as you’re using pnpm, have you configured the hoisting pattern (that should be mentioned in the docs but I can’t find anymore)?
yibuh
yibuhOP14mo ago
I did not, that should be the issue. I switched back to npm as I wasn't able to fix it. Thank you 🙂
Solution
Favna
Favna14mo ago
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.
Want results from more Discord servers?
Add your server