-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Improve typesafety of Snowflake #5157
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the typescript
dependency needs to be bumped to 4.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That... works... I wasn't aware ${number}
was a thing:
Only thing though, it allows decimals, but it's still better than nothing. Playground here.
Edit: Playground for ${bigint}
for 20cbac9, this solved decimals inside numbers, and seems to forbid the n
suffix (which BigInts use).
Once CI's errors are solved, this is good to go.
Fixed by doing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/pizzafox/discord.js/blob/cdb6646c9da782461d09a4823924a037aea9f38c/typings/index.d.ts#L2853
this type and possibly others need to be updated to string | Snowflake
a MessageReactionResolvable can also be name:id
which does not match `${bigint}`
Since discord_api_types is now a dependency, this (and many others) could be imports instead |
This PR is kind of dead anyway, the requested changes weren't made and @vaporox has a bigger typings PR anyway before we release v13 (currently it was closed because the changes would conflict too much with bigger PRs) |
Please describe the changes this PR makes and why it should be merged:
Since
Snowflake
s are always numbers in string form, this updates the type to use a template literal type, which will grant TypeScript users safe usage of the type.Status
Semantic versioning classification: