Module augmentation does not work

I recently updated my project with the latest versions of typescript and @sapphire/framework, and then I run into the problem that augmenting typing no longer works. I thought the problem would be pnpm, I even tried with the .npmrc configuration file "shamefully-hoist=true" but I'm still trying with yarn and the same thing happens, I don't know what to do. These are the versions I am using and my tsconfig file.
{
"typescript": "5.3.3",
"@sapphire/framework": "^5.0.7"
}
{
"typescript": "5.3.3",
"@sapphire/framework": "^5.0.7"
}
// tsconfig.base.json
{
"extends": [
"@sapphire/ts-config",
"@sapphire/ts-config/extra-strict",
"@sapphire/ts-config/decorators"
],
"compilerOptions": {
"skipLibCheck": true
}
}
// tsconfig.base.json
{
"extends": [
"@sapphire/ts-config",
"@sapphire/ts-config/extra-strict",
"@sapphire/ts-config/decorators"
],
"compilerOptions": {
"skipLibCheck": true
}
}
// src/tsconfig.json
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./",
"rootDir": "./",
"outDir": "../dist",
"composite": true,
"preserveConstEnums": true,
"lib": [
"DOM",
"ES2021.String"
],
"paths": {
"#decorators/guild": [
"lib/decorators/guild/index"
],
"#decorators/common": [
"lib/decorators/common/index"
],
"#decorators/api": [
"lib/decorators/api/index"
],
"#database/types": [
"lib/database/types/index"
],
"#database/adapters": [
"lib/database/adapters/index"
],
"#database/entities": [
"lib/database/entities/index"
],
"#database/setup": [
"lib/database/setup"
],
"#enums": [
"lib/enums/index"
],
"#services": [
"lib/services/index"
],
"#structures": [
"lib/structures/index"
],
"#functions/*": [
"lib/functions/*"
],
"#lib/*": [
"lib/*"
],
"#root/*": [
"/*"
]
}
},
"include": [
".",
"./locales/**/*.json",
]
}
// src/tsconfig.json
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./",
"rootDir": "./",
"outDir": "../dist",
"composite": true,
"preserveConstEnums": true,
"lib": [
"DOM",
"ES2021.String"
],
"paths": {
"#decorators/guild": [
"lib/decorators/guild/index"
],
"#decorators/common": [
"lib/decorators/common/index"
],
"#decorators/api": [
"lib/decorators/api/index"
],
"#database/types": [
"lib/database/types/index"
],
"#database/adapters": [
"lib/database/adapters/index"
],
"#database/entities": [
"lib/database/entities/index"
],
"#database/setup": [
"lib/database/setup"
],
"#enums": [
"lib/enums/index"
],
"#services": [
"lib/services/index"
],
"#structures": [
"lib/structures/index"
],
"#functions/*": [
"lib/functions/*"
],
"#lib/*": [
"lib/*"
],
"#root/*": [
"/*"
]
}
},
"include": [
".",
"./locales/**/*.json",
]
}
// src/lib/index.d.ts
declare module '@sapphire/pieces' {
interface Container {
i18n: I18nClient;
services: {
anilist: AnilistService;
// More here
};
}
}

export default undefined;
// src/lib/index.d.ts
declare module '@sapphire/pieces' {
interface Container {
i18n: I18nClient;
services: {
anilist: AnilistService;
// More here
};
}
}

export default undefined;
No description
Solution:
normally module augments should work just fine if everything is done right though. The last time I had difficulties was when I had incorrectly published some package (i think it was pieces) where it was missing some files in dist. Maybe check that out for your own packages? Check the files array and check the dist?
Jump to solution
6 Replies
Sawako
SawakoOP10mo ago
Well, I found the problem, it's my subcommand package, but I don't understand why I can't extend from the sapphire command class.
Sawako
SawakoOP10mo ago
No description
Favna
Favna10mo ago
bit hard to tell but FWIW the base sapphire sub commands plugin also doesnt module augment the command class. With how that is designed there is no reason to because subcommands are their own class with their own properties and they dont augment commands at runtime either so there is no need to module augment either
Solution
Favna
Favna10mo ago
normally module augments should work just fine if everything is done right though. The last time I had difficulties was when I had incorrectly published some package (i think it was pieces) where it was missing some files in dist. Maybe check that out for your own packages? Check the files array and check the dist?
Sawako
SawakoOP10mo ago
I'll take a look at it, but I find it weird that it doesn't work now because I haven't changed anything about the package.json and it was working fine before, a bit weird. Something I don't understand, is that if I copy literally the same code but in the code of my project it works correctly.
Favna
Favna10mo ago
Hm kaname left again. I'll assume that he figured it out. Marking as resolved.
Want results from more Discord servers?
Add your server