google / google/closure-compiler
Set.has, Map.get (etc.) should allow nullable value arg
Open
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Currently the externs type `Set.has(v)` such that `v` is `VALUE` i.e. the generic type of the collection. The same goes for `Map.get(k)` etc.
https://github.com/google/closure-compiler/blob/master/externs/es6_collections.js#L191
Would you consider accepting a PR to relax this to allow null? There are many cases particularly when working with legacy code where types are implicitly nullable, and it requires explicit casting every time you lookup a value in a set or map (even if the collection won't ever actually contain null, or the lookup be passed null, in practice).
Contributor guide
Assessment
This issue has not been assessed yet.