Impossible to transform from a discriminated union to another using a different discriminant field #35140
Labels
Design Limitation
Constraints of the existing architecture prevent this from being fixed
It does not seem to be possible to change the discriminant from one property to another and have that recognised as the proper type.
TypeScript Version: 3.8.0-dev.20191116
Search Terms: discriminated union, discriminant, kind, type
Code
Expected behavior:
Object returned by
makeVehicle
should successfully be interepreted by the compiler as aVehicle
Actual behavior:
Does not compile with the following error:
Playground Link:
http://www.typescriptlang.org/play/?ts=3.8.0-dev.20191115&ssl=31&ssc=36&pln=30&pc=53#code/JYOwLgpgTgZghgYwgAgMJysg3gKGcga1ABMAuZAcgQwr2TCgFcQCBlYALwnJEYFsARtBwBfHDlCRYiFACFgBFLnxEQZSgIURa+ABZw1AGwgCMqAPaHzUcgGcGoAOajxk6PCTIAggAdg6TGV6AE8fbkpqKB16JhZ2Lh5+ISgXCXB3GW8-eUVsOjBQ8IpNRWj9IxMzS2s7BxBnMRwCsOQANQhdYARjZABeNAxkAB8AApyIcWaUX2B2zu6UfpmA4azgcfEEcxB7ZGYCEHMAdxA+vPwp8ioaABp82LZOcIBWVJhmBDBgbeQ+OEU5l1jAAKABuHSB4RmgIWAEpyDCekEoBAwIwoKcsMgAHS48HzYw3Qgkcj4yHYqbIMQiIA
The text was updated successfully, but these errors were encountered: