Open
Description
TypeScript Version: 3.4.5 vs versions after 3.5
Search Terms: set constructor setconstructor unknown
Code
let s = new Set();
Expected behavior:
In TS 3.4: we expect the default chosen param to give us a Set<{}>
.
In TS 3.5: we expect a Set<unknown>
.
That change was an intended change in TS 3.5.
Or, if Set has a default generic arg, I expect the same default chosen in 3.4 and 3.5.
Actual behavior:
In TS 3.4, this actually was a Set<any>
!
It appears there are multiple overloads of the Set constructor.
lib.es2015.collection.d.ts says:
new <T = any>(values?: ReadonlyArray<T> | null): Set<T>;
while lib.es2105.iterable.d.ts says:
new <T>(iterable?: Iterable<T> | null): Set<T>;
Note that one has T = any
and the other doesn't.
So somehow TS 3.4 vs TS 3.5 decided to change whether to obey the any
default, I think?