-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
🔎 Search Terms
"debug failure completionInfo", "module augmentation breaks autocomplete classes"
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
completionInfodebug failure, or classes IntelliSense autocomplete. - I was unable to test this on prior versions because
@sapphire/frameworkmodule types seems to not work below TypeScript 4.
⏯ Playground Link
💻 Code
import "discord.js";
import { Command } from "@sapphire/framework";
class PingCommand extends Command {
// Press [CTRL + SPACE] to see autocomplete. It seems to work only in TypeScript playground,
// but if you try this same scenario in VSCode, then it seems to not show any "Command" class
// methods & properties, but it should.
}- This seems to be a TypeScript issue and not the
@sapphire/frameworkpackage, will explain why in additional information about the issue.
🙁 Actual behavior
In VSCode, pressing CTRL + SPACE inside the class definition doesn't show the extended class methods & properties, but it should, as it works with any other extended class.
- This happens on VSCode Insiders too.
- Tried also installing
typescript@nextand this issue still happens.
- TypeScript version: 5.4.5
- VSCode TypeScript version: Same as project (VSCode uses the
node_modulelib). - TSServer logs: tsserver.log
🙂 Expected behavior
VSCode should've shown in the IntelliSense autocomplete the extended class methods & properties, as it seems to do so in the TypeScript playground.
Additional information about the issue
The Command class in the @sapphire/framework package extends a lot of classes; following a hierarchy, goes like this: Command extends AliasPiece, AliasPiece extends Piece.
Before I continue, first I'd like to recall that the
Commandclass is located in another module (@sapphire/framework), and theAliasPieceandPiececlasses are located in another module (@sapphire/pieces).
If I remove in the AliasPiece class the extending Piece class, then the autocomplete seems to work as expected, therefore, we can assume that there's something in the Piece class that's causing the issue. And there is.
The Piece command has a get accessor called container that has the type of Container.

This Container type (to be specific, interface) has the following body:

The Container type is located in the @sapphire/pieces package. However, if we continue looking, we can see that the @sapphire/framework package types does module augmentation to that Container type:

Deleting that Container interface in the module augmentation seems to fix the issue with the autocomplete (but obviously, we don't want to delete that interface as it is important to use module augmentation in this case).
Therefore, I came with the conclusion that maybe this could be an issue with module augmentation feature.
I took a look at logs and couldn't find anything related to module augmentation, but at least there's an error that happens exactly when I do CTRL + SPACE in the class definition, specifying that this is a "debug failure"? Unsure how TypeScript server works behind the scenes, but what I find weird is that this works in TypeScript playground and not in VSCode...