TypeScript Version: 4.1.0-dev
In #40598 we added logic to reduce intersections of string literal types and template literal types. This logic incorrectly produces single-element intersections instead of reducing to the single constituent type. This means that '0' and `'0' & `${number}` are not considered identical--even though they display as the same type!
Code
var x: '0';
var x: '0' & `${number}`; // Error: 'x' must be of type '"0"', but here has type '"0"'
Expected behavior:
No error.
Actual behavior:
Error as shown above.
Playground Link:
https://www.typescriptlang.org/play?ts=4.1.0-dev.20201015#code/G4QwTgBAHgXBDkAGeBuAUKSsHIgMggAMASAbwDsBXAWwCMBTMAX0JQggHoOIBRMMAPZg48KPAjVKAZwAuEBhAEAzCDICeAB3oIARIh3wANPMpyAFo21mQU1Zu3w9BtEA
Related Issues: #40598
TypeScript Version: 4.1.0-dev
In #40598 we added logic to reduce intersections of string literal types and template literal types. This logic incorrectly produces single-element intersections instead of reducing to the single constituent type. This means that
'0'and`'0' & `${number}`are not considered identical--even though they display as the same type!Code
Expected behavior:
No error.
Actual behavior:
Error as shown above.
Playground Link:
https://www.typescriptlang.org/play?ts=4.1.0-dev.20201015#code/G4QwTgBAHgXBDkAGeBuAUKSsHIgMggAMASAbwDsBXAWwCMBTMAX0JQggHoOIBRMMAPZg48KPAjVKAZwAuEBhAEAzCDICeAB3oIARIh3wANPMpyAFo21mQU1Zu3w9BtEA
Related Issues: #40598