-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(TypeGuards): add TypeGuards
utility for commonly used data types
#6410
Conversation
Co-authored-by: Shubham Parihar <shubhamparihar391@gmail.com>
Co-authored-by: Shubham Parihar <shubhamparihar391@gmail.com>
Co-authored-by: Shubham Parihar <shubhamparihar391@gmail.com>
Co-authored-by: Shubham Parihar <shubhamparihar391@gmail.com>
Co-authored-by: Shubham Parihar <shubhamparihar391@gmail.com>
Co-authored-by: Shubham Parihar <shubhamparihar391@gmail.com>
Co-authored-by: Shubham Parihar <shubhamparihar391@gmail.com>
…/discord.js into util/type-guards
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.
I don't know if this is needed, since TS can infer from the properties if we have done unions right, but LGTM
You're correct, but I find doing having to do An alternative would be to split up the interfaces even more (add another interface for each variant, one for strings one for enums). But I dunno how I feel about that either. |
On reevaluation it seems that |
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
…/discord.js into util/type-guards
I think something like this might be better suited for |
That's fine by me. Should I close this now and wait for that repo to be published? |
Our modules are usually in the https://github.com/discordjs/discord.js-modules repo. You could theoretically look at the REST module and branch out your own if you wanted to in a PR. All we require is it having tests and the structure you can see how REST is built. |
Sweet! I'll take a look |
Please describe the changes this PR makes and why it should be merged:
Allows for easier type narrowing, for example:
Closes #6409
Status and versioning classification: