-
Notifications
You must be signed in to change notification settings - Fork 12.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
Add readonly typings for Set and Map #10921
Conversation
Similar to ReadonlyArray, these typings remove the mutation methods from Set and Map so that they can only be initialized by the constructor.
Hi @gmoothart, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
thanks @gmoothart. can you please sign the CLA? |
Also corrected some parameter names.
thisArg?: any): void; | ||
get(key: K): V|undefined; | ||
has(key: K): boolean; | ||
readonly size: number; |
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.
Please match the formatting for the rest of the file, that is 4 spaces.
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.
Some formatting changes, and we still need the CLA signed to be able to proceed.
forEach( | ||
callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, | ||
thisArg?: any): void; | ||
get(key: K): V|undefined; |
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.
and the spacing as well.
I guess for the CLA i need to talk to @naomiblack. |
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.
👍
Formatting fixed. I also updated some parameters names which were wrong, and fixed the example. It would be nice to be able to have type inference for the generic parameters, but I don't think it's possible in this case? Re: the CLA, there is a custom Google/Microsoft one that I did sign and yeah, Naomi should be able to help you. |
microsoft#10921 added readonly maps and sets, similar to ReadonlyArray. This adds the iterator methods [Symbol.iterator], keys(), values(), and entries() to them as well.
Fixes #10919
Similar to ReadonlyArray, these typings remove the mutation methods from Set and Map so that they can only be initialized by the constructor.
Example