mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
types(Client): fix isReady narrowing (#9828)
* types(Client): fix isReady narrowing * chore: add requested changes * chore: test both ready cases --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
2
packages/discord.js/typings/index.d.ts
vendored
2
packages/discord.js/typings/index.d.ts
vendored
@@ -955,6 +955,8 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
||||
private _eval(script: string): unknown;
|
||||
private _validateOptions(options: ClientOptions): void;
|
||||
private get _censoredToken(): string | null;
|
||||
// This a technique used to brand the ready state. Or else we'll get `never` errors on typeguard checks.
|
||||
private readonly _ready: Ready;
|
||||
|
||||
public application: If<Ready, ClientApplication>;
|
||||
public channels: ChannelManager;
|
||||
|
||||
@@ -197,6 +197,12 @@ const client: Client = new Client({
|
||||
}),
|
||||
});
|
||||
|
||||
if (client.isReady()) {
|
||||
expectType<Client<true>>(client);
|
||||
} else {
|
||||
expectType<Client>(client);
|
||||
}
|
||||
|
||||
const testGuildId = '222078108977594368'; // DJS
|
||||
const testUserId = '987654321098765432'; // example id
|
||||
const globalCommandId = '123456789012345678'; // example id
|
||||
|
||||
Reference in New Issue
Block a user