Skip to content

Commit 2e6ad68

Browse files
committed
chore: bye tsd
1 parent 9f1fa8c commit 2e6ad68

17 files changed

+241
-1029
lines changed

package-lock.json

Lines changed: 4 additions & 832 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@
112112
"prepare": "tsc -p ./.eslint-plugin-local && (is-ci || husky)",
113113
"prepublishOnly": "run-s clean test:lint build:node",
114114
"test:lint": "prettier --check . && eslint --ext mjs,ts \"{gateway,payloads,rest,rpc,voice,utils}/**/*.ts\" \"{globals,v*}.ts\" \"scripts/**/*.mjs\"",
115-
"pretest:types": "tsc",
116-
"test:types": "tsd -t ./v10.d.ts && tsd -t ./v9.d.ts",
117-
"posttest:types": "npm run clean:node"
115+
"test:types": "tsc -p tests"
118116
},
119117
"keywords": [
120118
"discord",
@@ -152,7 +150,6 @@
152150
"prettier": "^3.2.5",
153151
"pretty-quick": "^4.0.0",
154152
"rimraf": "^6.0.0",
155-
"tsd": "^0.31.2",
156153
"tsutils": "^3.21.0",
157154
"typescript": "^5.6.3"
158155
},

tests/__utils__/type-assertions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export declare function expectAssignable<T>(input: T): void;
2+
3+
// TODO: no clue if this is correct
4+
export declare function expectNotAssignable<Expected, Actual = unknown>(
5+
input: Actual extends Expected ? never : Expected,
6+
): void;

tests/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": ["../tsconfig.json"],
3+
"compilerOptions": {
4+
"noEmit": true,
5+
"noUnusedLocals": false
6+
},
7+
"include": ["./**/*.ts"]
8+
}

tests/v10/channel.test-d.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

tests/v10/channel.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type {
2+
ChannelType,
3+
APIPartialChannel,
4+
APIGroupDMChannel,
5+
APIDMChannel,
6+
APIGuildChannel,
7+
APITextChannel,
8+
APIThreadChannel,
9+
APIGuildVoiceChannel,
10+
APIGuildStageVoiceChannel,
11+
} from '../../v10';
12+
import { expectAssignable, expectNotAssignable } from '../__utils__/type-assertions';
13+
14+
type AnyGuildChannel = APIGuildChannel<ChannelType>;
15+
16+
declare const partialChannel: APIPartialChannel;
17+
declare const dmChannel: APIDMChannel;
18+
declare const groupDMChannel: APIGroupDMChannel;
19+
declare const guildChannel: AnyGuildChannel;
20+
declare const guildTextChannel: APITextChannel;
21+
declare const guildThreadChannel: APIThreadChannel;
22+
declare const guildVoiceChannel: APIGuildVoiceChannel;
23+
declare const guildVoiceStageChannel: APIGuildStageVoiceChannel;
24+
25+
// Make sure types follow expected hierarchy
26+
// @ts-expect-error - dmChannel is not assignable to AnyGuildChannel
27+
expectNotAssignable<AnyGuildChannel>(dmChannel);
28+
// @ts-expect-error - groupDMChannel is not assignable to AnyGuildChannel
29+
expectNotAssignable<AnyGuildChannel>(groupDMChannel);
30+
expectAssignable<AnyGuildChannel>(guildTextChannel);
31+
expectAssignable<AnyGuildChannel>(guildThreadChannel);
32+
expectAssignable<AnyGuildChannel>(guildVoiceChannel);
33+
expectAssignable<AnyGuildChannel>(guildVoiceStageChannel);
34+
35+
// Test channel names are properly typed
36+
// Always non-null present for non-DM channels, always null for DM channel
37+
expectAssignable<string | null | undefined>(partialChannel.name);
38+
expectAssignable<string | null>(groupDMChannel.name);
39+
expectAssignable<null>(dmChannel.name);
40+
expectAssignable<string>(guildChannel.name);
41+
42+
// Test last pin timestamp
43+
expectAssignable<string | null | undefined>(dmChannel.last_pin_timestamp);
44+
expectAssignable<string | null | undefined>(groupDMChannel.last_pin_timestamp);
45+
expectAssignable<string | null | undefined>(guildTextChannel.last_pin_timestamp);
46+
expectAssignable<string | null | undefined>(guildThreadChannel.last_pin_timestamp);
47+
48+
let _: any;
49+
50+
// @ts-expect-error - last_pin_timestamp does not exist on this channel type
51+
_ = guildVoiceChannel.last_pin_timestamp;
52+
// @ts-expect-error - last_pin_timestamp does not exist on this channel type
53+
_ = guildVoiceStageChannel.last_pin_timestamp;
54+
55+
// Test rate limit types
56+
expectAssignable<number | undefined>(guildTextChannel.default_thread_rate_limit_per_user);
57+
58+
// @ts-expect-error - default_thread_rate_limit_per_user does not exist on this channel type
59+
_ = guildVoiceChannel.default_thread_rate_limit_per_user;

tests/v10/chatInputOptions.test-d.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

tests/v10/chatInputOptions.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import type {
2+
APIApplicationCommandIntegerOption,
3+
APIApplicationCommandNumberOption,
4+
APIApplicationCommandOption,
5+
APIApplicationCommandStringOption,
6+
} from '../../v10';
7+
import { ApplicationCommandOptionType } from '../../v10';
8+
9+
const baseValues = {
10+
name: 'test',
11+
description: 'test',
12+
};
13+
14+
{
15+
const option: APIApplicationCommandStringOption = {
16+
...baseValues,
17+
type: ApplicationCommandOptionType.String,
18+
autocomplete: true,
19+
};
20+
}
21+
22+
{
23+
const option: APIApplicationCommandIntegerOption = {
24+
...baseValues,
25+
type: ApplicationCommandOptionType.Integer,
26+
autocomplete: true,
27+
};
28+
}
29+
30+
{
31+
const option: APIApplicationCommandNumberOption = {
32+
...baseValues,
33+
type: ApplicationCommandOptionType.Number,
34+
autocomplete: true,
35+
};
36+
}
37+
38+
{
39+
const option: APIApplicationCommandStringOption = {
40+
...baseValues,
41+
type: ApplicationCommandOptionType.String,
42+
choices: [],
43+
};
44+
}
45+
46+
{
47+
const option: APIApplicationCommandStringOption = {
48+
...baseValues,
49+
type: ApplicationCommandOptionType.String,
50+
choices: [],
51+
autocomplete: true,
52+
};
53+
}
54+
55+
{
56+
const option: APIApplicationCommandStringOption = {
57+
...baseValues,
58+
type: ApplicationCommandOptionType.String,
59+
choices: [],
60+
autocomplete: false,
61+
};
62+
}
63+
64+
{
65+
const option: APIApplicationCommandNumberOption = {
66+
...baseValues,
67+
type: ApplicationCommandOptionType.Number,
68+
choices: [],
69+
};
70+
}
71+
72+
{
73+
const option: APIApplicationCommandOption = {
74+
...baseValues,
75+
type: ApplicationCommandOptionType.Boolean,
76+
// @ts-expect-error - autocomplete is not allowed on booleans
77+
autocomplete: true,
78+
};
79+
}

tests/v10/interactions.test-d.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)