You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This actually looks to be a regression caused by #19745. A simple repro:
declare function foo<T>(a?: ReadonlyArray<T>): T;
let x = foo([]); // never | ReadonlyArray<never> | undefined
The issue is that when inferring from Array<T> to ReadonlyArray<T> we structurally relate the types, which produces a number of secondary inferences. Usually these secondary inferences are suppressed by a higher priority inference of never, but with #19745 that doesn't happen (because inferences from an implicit never[] are given even lower priority).
This regression, it happens with common cases and makes a large impact, shouldn't be released with the next stable version. Should be fixed by no later than the next releasing.
#20606 should be reverted for now.
TypeScript Version: master
Code
Expected behavior:
Set<never>
Actual behavior:
Set<never | ReadonlyArray<never> | undefined>
Related:
The text was updated successfully, but these errors were encountered: