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

docs: undocument private constructors #6732

Merged

Conversation

SpaceEEC
Copy link
Member

@SpaceEEC SpaceEEC commented Oct 1, 2021

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

This PR removes documentation for private constructors.
Those being documented confused library consumers into thinking that they are supposed / intended to instantiate those classes themselves.

Some constructors were intended to be documented due to Structures.extend use-cases, but this feature has, since then, been removed.

Changed classes:

  • Shard
  • ShardClientUtil
  • BaseGuildTextChannel
  • ClientPresence
  • DMChannel
  • GuildBan
  • GuildChannel
  • GuildEmoji
  • GuildTemplate
  • Message
  • MessageReaction
  • Presence
  • Role
  • Sticker
  • StickerPack
  • StoreChannel
  • ThreadChannel
  • ThreadMember
  • Typing
  • User
  • VoiceState
  • Widget
  • WidgetMember

This PR also modifies the types to no longer allow instantiation where unintended, this includes few more classes than listed above.

Status and versioning classification:

  • 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
  • This PR only includes non-code changes, like changes to documentation, README, etc.

src/structures/GuildBan.js Show resolved Hide resolved
src/structures/GuildTemplate.js Show resolved Hide resolved
src/structures/MessageReaction.js Show resolved Hide resolved
src/structures/ClientPresence.js Show resolved Hide resolved
src/structures/Sticker.js Show resolved Hide resolved
src/structures/StickerPack.js Show resolved Hide resolved
src/structures/ThreadMember.js Show resolved Hide resolved
src/structures/Typing.js Show resolved Hide resolved
src/structures/VoiceState.js Show resolved Hide resolved
Copy link
Contributor

@ImRodry ImRodry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was gonna submit the review about the external links as soon as Jiralite did it so LGTM xD

Copy link
Contributor

@ImRodry ImRodry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, most of these constructors are public in the typings, could you go through them and make them private?

@iCrawl iCrawl requested review from kyranet and vladfrangu October 2, 2021 11:36
@iCrawl iCrawl merged commit 34b2ad0 into discordjs:main Oct 3, 2021
@iCrawl iCrawl added this to the Version 13.2 milestone Oct 3, 2021
@tremby
Copy link

tremby commented Oct 12, 2021

Is there a way, short of @ts-expect-error, I can opt out of this for my tests? I use these constructors to produce fixtures for the purpose of unit testing my application.

@kyranet
Copy link
Member

kyranet commented Oct 13, 2021

There is one: Reflect.construct().

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.

7 participants