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

types(collection): simplify ambient constructor declaration #10549

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

Renegade334
Copy link
Contributor

@Renegade334 Renegade334 commented Oct 11, 2024

collection.ts needs an ambient declaration for Collection.prototype.constructor in order for the TypeScript compiler to understand this.constructor[Symbol.species] references within class methods.

The existing implementation of this is a little clumsy. This refactor simplifies the declaration significantly, and also removes the risk of the constructor property type becoming out-of-sync with Collection if changes are made to the constructor.

Removes the redundant CollectionConstructor interface which, although exported, is marked @internal and doesn't appear in the docs, therefore should probably be OK to count as a non-breaking change.

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

Copy link

vercel bot commented Oct 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
discord-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 7, 2024 11:07am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Nov 7, 2024 11:07am

- deduplicates constructor definition
- removes Collection's "internal" JSDoc description block
- removes unnecessary `extends` clause
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.97%. Comparing base (ea04245) to head (e2cff22).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10549      +/-   ##
==========================================
- Coverage   38.16%   37.97%   -0.19%     
==========================================
  Files         239      239              
  Lines       15500    15433      -67     
  Branches     1371     1366       -5     
==========================================
- Hits         5915     5861      -54     
+ Misses       9570     9557      -13     
  Partials       15       15              
Flag Coverage Δ
collection 100.00% <ø> (ø)
proxy 66.27% <ø> (ø)
rest 87.37% <ø> (ø)
ws 36.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kodiakhq kodiakhq bot merged commit c973106 into discordjs:main Nov 7, 2024
24 checks passed
@Renegade334 Renegade334 deleted the collection-constructor-types branch November 7, 2024 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants