Skip to content

fix(Types): replace never usage with void#1526

Open
PapiOphidian wants to merge 3 commits intodiscordjs:mainfrom
PapiOphidian:fix/replace-never-void
Open

fix(Types): replace never usage with void#1526
PapiOphidian wants to merge 3 commits intodiscordjs:mainfrom
PapiOphidian:fix/replace-never-void

Conversation

@PapiOphidian
Copy link

Please describe the changes this PR makes and why it should be merged:
closes #1522

The majority of the usage of never in the project does not align with the semantics of the keyword and this PR replaces them with void. The keyword implies the value being typed as never cannot be observed under any conditions such as in the case of only throwing an exception or process.exit(), which is not true in cases of where these types would be used such as return types for routes that return an HTTP 204 which is an OK status code.
It's also used in some gateway payloads which is also technically incorrect as attempting to access the values at runtime would produce an observable undefined.

Some of the base types for gateway payloads that would have been modified would not work to be replaced as void, so those have been kept.
API v6-v8 also has not been modified as those had clear deprecation comments, but it was assumed that api v9 was still being maintained, so types from v9 have also been modified.

Some markdown mentioning the usage of never has also been modified.

If applicable, please reference Discord API Docs PRs or commits that influenced this PR:
N.A.

@vercel
Copy link

vercel bot commented Feb 16, 2026

@PapiOphidian is attempting to deploy a commit to the discordjs Team on Vercel.

A member of the Team first needs to authorize it.

@vladfrangu
Copy link
Member

Some of the base types for gateway payloads that would have been modified would not work to be replaced as void, so those have been kept

Which ones? 👁️

@vladfrangu
Copy link
Member

Also should we use undefined instead of void?

@Jiralite
Copy link
Member

I think for types like this one:

export type RPCSubscribeEntitlementDeleteArgs = Record<string, void>;

undefined might fit better. It's like saying an object comprises solely of keys?

@vladfrangu
Copy link
Member

I'm confused what that type even is, cuz surely its not an object of keys...

@PapiOphidian
Copy link
Author

It was the heartbeat and reconnect packets that I couldn't change to void without some ts errors. I hadn't considered undefined, but I do believe undefined could work better and it addresses the issue of those packets not being able to be changed from never. I've updated the usages I'd previously updated as well as documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP 204 route result types should be void instead of never

3 participants