@todo(111): the following fails - find a better way
export type SingleOrWeak = Single | Exclude<WeakSet | WeakMap<any, any>, Map<any, any> | Set>
Weak containers are a special case: they might have many nested items internally, but they are not iterable, hence practically they are not "Many" nor "Single" types either!
Note: another technical reason is that if we add WeakXxx to Single, it breaks to also match Set & Map, which is awful! So we keep these off strict Single.
Matches a Single or a WeakSet or WeakMap (BUT unfortunately also Set & Map). So, it is BROKEN! Use
IsSingleOrWeak
instead that works fine!The following both fail, cause
WeakSet
&WeakMap
are not consideredSingle
types:expectType<TypeOf<SingleOrWeak, Set>>(false)
expectType<TypeOf<SingleOrWeak, Map<any, any>>>(false)
@todo(111): the following fails - find a better way export type SingleOrWeak = Single | Exclude<WeakSet | WeakMap<any, any>, Map<any, any> | Set>
Weak containers are a special case: they might have many nested items internally, but they are not iterable, hence practically they are not "Many" nor "Single" types either!
Note: another technical reason is that if we add
WeakXxx
toSingle
, it breaks to also matchSet
&Map
, which is awful! So we keep these off strictSingle
.We can use
IsSingleOrWeak
till then.