mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 11:03:30 +01:00
types(interactions): fix overloads (#10702)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,7 @@ const api = new API(rest);
|
||||
const SNOWFLAKE = '123456789012345678' as const;
|
||||
const TOKEN = 'token' as const;
|
||||
const MODAL_COMPONENTS: APIActionRowComponent<APIModalActionRowComponent>[] = [] as const;
|
||||
const boolValue = true as boolean;
|
||||
|
||||
describe('Interaction with_response overloads.', () => {
|
||||
test('Replying returns RESTPostAPIInteractionCallbackWithResponseResult.', () =>
|
||||
@@ -19,39 +20,82 @@ describe('Interaction with_response overloads.', () => {
|
||||
api.interactions.reply(SNOWFLAKE, TOKEN, { with_response: true }),
|
||||
));
|
||||
|
||||
test('Replying returns undefined.', () =>
|
||||
assertType<Promise<undefined>>(api.interactions.reply(SNOWFLAKE, TOKEN, {})));
|
||||
test('Replying returns undefined.', () => {
|
||||
assertType<Promise<undefined>>(api.interactions.reply(SNOWFLAKE, TOKEN, {}));
|
||||
assertType<Promise<undefined>>(api.interactions.reply(SNOWFLAKE, TOKEN, { with_response: false }));
|
||||
});
|
||||
|
||||
test('Replying returns either RESTPostAPIInteractionCallbackWithResponseResult or undefined.', () => {
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult | undefined>>(
|
||||
api.interactions.reply(SNOWFLAKE, TOKEN, { with_response: boolValue }),
|
||||
);
|
||||
});
|
||||
|
||||
test('Defer returns RESTPostAPIInteractionCallbackWithResponseResult.', () =>
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult>>(
|
||||
api.interactions.defer(SNOWFLAKE, TOKEN, { with_response: true }),
|
||||
));
|
||||
|
||||
test('Defer returns undefined.', () => assertType<Promise<undefined>>(api.interactions.defer(SNOWFLAKE, TOKEN, {})));
|
||||
test('Defer returns undefined.', () => {
|
||||
assertType<Promise<undefined>>(api.interactions.defer(SNOWFLAKE, TOKEN));
|
||||
assertType<Promise<undefined>>(api.interactions.defer(SNOWFLAKE, TOKEN, { with_response: false }));
|
||||
});
|
||||
|
||||
test('Defer returns either RESTPostAPIInteractionCallbackWithResponseResult or undefined.', () => {
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult | undefined>>(
|
||||
api.interactions.defer(SNOWFLAKE, TOKEN, { with_response: boolValue }),
|
||||
);
|
||||
});
|
||||
|
||||
test('Defer message update returns RESTPostAPIInteractionCallbackWithResponseResult.', () =>
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult>>(
|
||||
api.interactions.deferMessageUpdate(SNOWFLAKE, TOKEN, { with_response: true }),
|
||||
));
|
||||
|
||||
test('Defer message update returns undefined.', () =>
|
||||
assertType<Promise<undefined>>(api.interactions.deferMessageUpdate(SNOWFLAKE, TOKEN, {})));
|
||||
test('Defer message update returns undefined.', () => {
|
||||
assertType<Promise<undefined>>(api.interactions.deferMessageUpdate(SNOWFLAKE, TOKEN));
|
||||
assertType<Promise<undefined>>(api.interactions.deferMessageUpdate(SNOWFLAKE, TOKEN, { with_response: false }));
|
||||
});
|
||||
|
||||
test('Defer message update returns either RESTPostAPIInteractionCallbackWithResponseResult or undefined.', () => {
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult | undefined>>(
|
||||
api.interactions.deferMessageUpdate(SNOWFLAKE, TOKEN, { with_response: boolValue }),
|
||||
);
|
||||
});
|
||||
|
||||
test('Update message returns RESTPostAPIInteractionCallbackWithResponseResult.', () =>
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult>>(
|
||||
api.interactions.updateMessage(SNOWFLAKE, TOKEN, { with_response: true }),
|
||||
));
|
||||
|
||||
test('Update message returns undefined.', () =>
|
||||
assertType<Promise<undefined>>(api.interactions.updateMessage(SNOWFLAKE, TOKEN, {})));
|
||||
test('Update message returns undefined.', () => {
|
||||
assertType<Promise<undefined>>(api.interactions.updateMessage(SNOWFLAKE, TOKEN, {}));
|
||||
assertType<Promise<undefined>>(api.interactions.updateMessage(SNOWFLAKE, TOKEN, { with_response: false }));
|
||||
});
|
||||
|
||||
test('Update message returns either RESTPostAPIInteractionCallbackWithResponseResult or undefined.', () => {
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult | undefined>>(
|
||||
api.interactions.updateMessage(SNOWFLAKE, TOKEN, { with_response: boolValue }),
|
||||
);
|
||||
});
|
||||
|
||||
test('Create autocomplete response returns RESTPostAPIInteractionCallbackWithResponseResult.', () =>
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult>>(
|
||||
api.interactions.createAutocompleteResponse(SNOWFLAKE, TOKEN, { with_response: true }),
|
||||
));
|
||||
|
||||
test('Create autocomplete response returns undefined.', () =>
|
||||
assertType<Promise<undefined>>(api.interactions.createAutocompleteResponse(SNOWFLAKE, TOKEN, {})));
|
||||
test('Create autocomplete response returns undefined.', () => {
|
||||
assertType<Promise<undefined>>(api.interactions.createAutocompleteResponse(SNOWFLAKE, TOKEN, {}));
|
||||
assertType<Promise<undefined>>(
|
||||
api.interactions.createAutocompleteResponse(SNOWFLAKE, TOKEN, { with_response: false }),
|
||||
);
|
||||
});
|
||||
|
||||
test('Create autocomplete response returns either RESTPostAPIInteractionCallbackWithResponseResult or undefined.', () => {
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult | undefined>>(
|
||||
api.interactions.createAutocompleteResponse(SNOWFLAKE, TOKEN, { with_response: boolValue }),
|
||||
);
|
||||
});
|
||||
|
||||
test('Create modal returns RESTPostAPIInteractionCallbackWithResponseResult.', () =>
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult>>(
|
||||
@@ -63,8 +107,28 @@ describe('Interaction with_response overloads.', () => {
|
||||
}),
|
||||
));
|
||||
|
||||
test('Create modal returns undefined.', () =>
|
||||
test('Create modal returns undefined.', () => {
|
||||
assertType<Promise<undefined>>(
|
||||
api.interactions.createModal(SNOWFLAKE, TOKEN, { title: '', custom_id: '', components: MODAL_COMPONENTS }),
|
||||
));
|
||||
);
|
||||
assertType<Promise<undefined>>(
|
||||
api.interactions.createModal(SNOWFLAKE, TOKEN, {
|
||||
title: '',
|
||||
custom_id: '',
|
||||
components: MODAL_COMPONENTS,
|
||||
with_response: false,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test('Create modal returns either RESTPostAPIInteractionCallbackWithResponseResult or undefined.', () => {
|
||||
assertType<Promise<RESTPostAPIInteractionCallbackWithResponseResult | undefined>>(
|
||||
api.interactions.createModal(SNOWFLAKE, TOKEN, {
|
||||
title: '',
|
||||
custom_id: '',
|
||||
components: MODAL_COMPONENTS,
|
||||
with_response: boolValue,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user