jeelzzz
jeelzzz
SIASapphire - Imagine a framework
Created by jeelzzz on 12/6/2023 in #sapphire-support
Property does not exist on type 'Container'
i'm trying to use DI in typescript like on this page https://www.sapphirejs.dev/docs/Guide/additional-information/using-and-extending-container and i can't get it to work. my code is
export class MyClient extends SapphireClient {
public constructor() {
super(...optionsandstuff);
}

public override async login(token?: string) {
container.pollManager = new PollManager();
return super.login(token);
}
// destroy too
}

declare module '@sapphire/pieces' {
interface Container {
pollManager: PollManager;
}
}
export class MyClient extends SapphireClient {
public constructor() {
super(...optionsandstuff);
}

public override async login(token?: string) {
container.pollManager = new PollManager();
return super.login(token);
}
// destroy too
}

declare module '@sapphire/pieces' {
interface Container {
pollManager: PollManager;
}
}
but it gives the error Property 'pollManager' does not exist on type 'Container'. i'm using discord.js 14.14.1, @sapphire/framework 4.8.2, and typescript 5.3.2 with @sapphire/ts-config 5.0.0. i am really not sure what i'm doing wrong if anyone could help it would be greatly appreciated. thanks
4 replies