Skip to content
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(Types): support type-guarding using Channel#type string literal #3918

Merged
merged 8 commits into from Mar 14, 2020

Conversation

monbrey
Copy link
Member

@monbrey monbrey commented Mar 8, 2020

This PR adds three new union types to better define the return types of methods that return Channels, rather than having them all return the abstract classes Channel or GuildChannel.

By doing so, channel.type can be used as a type-guard in TS projects.

There are also a couple of other types improvements:

  • StoreChannel#type was missing, added
  • GuildChannel#setParent should accept CategoryChannel, not abstract GuildChannel

I haven't changed the type of function parameters being passed in as class extension is sufficient in these areas - open to discussion if this should also be done.

Status

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

typings/index.d.ts Outdated Show resolved Hide resolved
typings/index.d.ts Show resolved Hide resolved
typings/index.d.ts Outdated Show resolved Hide resolved
typings/index.d.ts Outdated Show resolved Hide resolved
monbrey and others added 5 commits March 10, 2020 07:08
Co-Authored-By: Sugden <28943913+NotSugden@users.noreply.github.com>
Co-Authored-By: Sugden <28943913+NotSugden@users.noreply.github.com>
@iCrawl iCrawl merged commit 69d69f2 into discordjs:master Mar 14, 2020
SpaceEEC added a commit to SpaceEEC/discord.js that referenced this pull request Mar 21, 2020
SpaceEEC added a commit to SpaceEEC/discord.js that referenced this pull request Mar 21, 2020
iCrawl added a commit that referenced this pull request Mar 27, 2020
* revert: channel unions (#3918 69d69f2)

* fix: correct tslint:disable

* revert: keep the GuildChannel#setParent change

Co-authored-by: Crawl <icrawltogo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants