You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This comes with other questions. For example, a lot of methods have callback parameters with this types, which are also resolved to Collection by the compiler; technically, these also give the opportunity to resolve a ReadonlyCollection to a Collection and call mutating methods on it.
Ultimately, the options are:
Refactor ReadonlyCollection to duplicate the definitions for all non-mutating Collection methods, rather than grabbing them from the Collection interface (example).
This is the approach taken by Microsoft for Readonly* interfaces within the TypeScript library, and would provide a self-contained interface where TypeScript's this type refers to ReadonlyCollection, which would render the method signatures fully non-mutable (including callback parameters etc.). However, this would be an awful lot of duplication here, and would impact on maintainability.
Leave things as they are, on the understanding that ReadonlyCollection is nothing more than Collection without the mutating methods, and isn't going to stop you from deriving a mutable Collection from the remaining methods.
We spoke about this internally and I think we wanted to do something along the lines of 1, but dynamic. You do raise a good point with the callbacks though. I'll try to draft up a PR.
My main concern is that I'm probably obliterating the docs readability for ReadonlyCollection, but.. I think it's probably already pretty bad & also not that important.
Which package is this bug report for?
collection
Issue description
I doubt this matters too much, but here it is anyway.
Steps to reproduce:
this
return type upon the Collection.ReadonlyCollection
type....set()
and.delete()
on the Collection.Code sample
Versions
Issue priority
Low (slightly annoying)
Which partials do you have configured?
Not applicable
Which gateway intents are you subscribing to?
Not applicable
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: