2 ms·
Great feature. Immutable.js supports something similar but at the access site: var m: Im.Map<string, Im.Set<string>> = Im.Map(); console.log(m.get('fo
by leebyron 12y ago
Great feature.
Immutable.js supports something similar but at the access site:
var m: Im.Map<string, Im.Set<string>> = Im.Map();
console.log(m.get('foo')); // maybe undefined
console.log(m.get('foo', Im.Set())); // never undefined
typescript (and soon, flow) checks that the second arg to .get() is a Value type. Flow has the concept of non-nullable types, which will eventually let us type the return value of `get(key: K): V?` differently from `get(key: K, otherwise: V): V`