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
{{ message }}
Repository navigation
[3.9.0 BUG] Recursive type infer behaves differently when passing type literal and passing type alias #37982
interfaceBox<T>{__: T}typeRecursive<T>=|T|Box<Recursive<T>>typeInferRecursive<T>=TextendsRecursive<infer R> ? R : "never!"// the type we are testing withtypet1=Box<string|Box<number|boolean>>typet2=InferRecursive<t1>typet3=InferRecursive<Box<string|Box<number|boolean>>>// write t1 explicitly// Why is t2 and t3 different??// They have same input type!
Expected behavior: t2 and t3 should be the same: string | number | boolean
Actual behavior: t2 is never. t3 is the expected string | number | boolean
changed the title [-]Recursive type infer behaves differently when passing type literal and passing type alias[/-][+][3.9.0 BUG] Recursive type infer behaves differently when passing type literal and passing type alias[/+]on Apr 15, 2020
Activity
csr632 commentedon Apr 15, 2020
In ts3.8.3, both t2 and t3 are
never. So this bug is introduced in 3.9.0.[-]Recursive type infer behaves differently when passing type literal and passing type alias[/-][+][3.9.0 BUG] Recursive type infer behaves differently when passing type literal and passing type alias[/+]csr632 commentedon Apr 15, 2020
Is there any way I can transform type t1 into
string | number | booleanwithout using hack?https://www.typescriptlang.org/v2/en/play?ts=3.9.0-beta&ssl=24&ssc=39&pln=24&pc=3#code/JYOwLgpgTgZghgYwgAgEIHsAeAeAKgPmQG8AoZZAfQoC5lcSBfEksATwAcUAlCBAVygBnYADcIeQgF4yyAD50Z8jDh78ho8QXzM2nZAEkQMaKoHCxE5JLrIImSCAAmg5KfUXQxqK8IB+V8i0AEQgEGJQAIRBzAD0MchgABYouigA7ihwUCkQgmCgAObIacBJLBwpAIxWaFjYeVCFcrU4IHwAtgBG0M2d6OgANhBwIPja5XpgAEw1hl5u5uJgldqpCQDMs0YmvGYa2Mr1YI0gRUp1bV098n2Dw6NjyHHFjZAJ1XbsA8AIpQOssXiAHVEqxkMAXNNkCNHBtkI5gDAvBBwL5fCRnrhkmDEnAxMhBHB2ihQOw+GAEhUIswJtxdu4IAAJRAAawolmspHIQRRjiCtHo3Oyan5NjsDmcLWwnh6XD8rnpi2ZCBZ2DlgWQoXCjAA2rhbPZeS5DiNWPKgsKBEENTynEEALoY+IIhrATrkjTIBDoJylYA+uADSmcWkKtRK1kcsWGpzGuqm+ULDTKtmWAUAbidBi9I2QfEEKFxKoS6GQBQgFLSuIp+mKIzAABpkO6KUkIeCXCB0BTheh2sSnBBYZ0wWBIcN2qGwAAWGpJsQp7DLfBAA