🔎 Search Terms
mapped type assignability regression
🕗 Version & Regression Information
- This changed between versions 5.3 and 5.4
⏯ Playground Link
Playground Link
💻 Code
typeValueType=string;typeBox<TextendsValueType>={v: T};typeTest<TextendsValueType[]>=TtypeUnboxArray<T>={[KinkeyofT]: T[K]extendsBox<infer R> ? R : never;};typeIdentity<T>={[KinkeyofT]: T[K]};declarefunctionfnBad<TextendsArray<Box<ValueType>>>(...args: T): Test<Identity<UnboxArray<T>>>;declarefunctionfnOk<TextendsArray<Box<ValueType>>>(...args: T): Test<UnboxArray<T>>;typeUnbox<T>=TextendsArray<Box<infer R>> ? Array<R> : never;declarefunctionfnSimilar<TextendsArray<Box<ValueType>>>(...args: T): Test<Identity<Unbox<T>>>;🙁 Actual behavior
Test<Identity<UnboxArray<T>>> is being reported as an error because Identity<UnboxArray<T>> is not assignable to the constraint of Test. Even more strange the error elaboration says Type 'Box<string>' is not assignable to type 'string' which is strange since the type that comes out of UnboxArray<T> can't have Box<string> as an item type. If we don't pass the type though the Identity mapped type, then UnboxArray<T> is assignable to ValueType[].
🙂 Expected behavior
Test<Identity<UnboxArray<T>>> should not be an error as it is in 5.3
Additional information about the issue
No response
🔎 Search Terms
mapped type assignability regression
🕗 Version & Regression Information
⏯ Playground Link
Playground Link
💻 Code
🙁 Actual behavior
Test<Identity<UnboxArray<T>>>is being reported as an error becauseIdentity<UnboxArray<T>>is not assignable to the constraint ofTest. Even more strange the error elaboration saysType 'Box<string>' is not assignable to type 'string'which is strange since the type that comes out ofUnboxArray<T>can't haveBox<string>as an item type. If we don't pass the type though theIdentitymapped type, thenUnboxArray<T>is assignable toValueType[].🙂 Expected behavior
Test<Identity<UnboxArray<T>>>should not be an error as it is in 5.3Additional information about the issue
No response