Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(Client): fix isReady narrowing #9828

Merged
merged 4 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Jiralite marked this conversation as resolved.
Show resolved Hide resolved

public application: If<Ready, ClientApplication>;
public channels: ChannelManager;
Expand Down
4 changes: 4 additions & 0 deletions packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ const client: Client = new Client({
}),
});

if (client.isReady()) {
didinele marked this conversation as resolved.
Show resolved Hide resolved
expectType<Client<true>>(client);
}

const testGuildId = '222078108977594368'; // DJS
const testUserId = '987654321098765432'; // example id
const globalCommandId = '123456789012345678'; // example id
Expand Down
Loading