{[K in T]: (arg: K) => void}[T]
has inconsistent/unsound behavior when T is a lazy-evaluated union
#48734
Labels
Duplicate
An existing issue was already created
Bug Report
π Search Terms
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
In 4.5.5,
fn3
doesn't report an error.In 4.6.2,
fn2
andfn3
doesn't report an error.I'm not sure but this maybe cause by #47109 or #47370 ?
π Expected behavior
Error reported in
fn1
andfn4
should also be reported infn2
andfn3
, because:U1
is equivalent toU2
, it is inconsistent wherefn1
reports error butfn2
does not.{[K in T]: G<K>}[T]
has a distributive behavior overT
, so I expect it behave the same as the conditional type formT extends unknown ? G<T> : never
, which reports error correctly asfn4
shows.fn3
:fn3<'foo' | 'bar'>((x: 'foo') => assert(x === 'foo'), 'bar')
The text was updated successfully, but these errors were encountered: