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.
Please match the formatting for the rest of the file, that is 4 spaces.
mhegazy
left a comment
There was a problem hiding this comment.
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; |
|
I guess for the CLA i need to talk to @naomiblack. |
|
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