I can get the vscode tip with number:
but when union with string failed:
CodePudding user response:
The canonical way to do this is to intersect string with {}. string normally would absorb string literal types in a union (the string literal types are already part of string so in effect they are redundant for type checking)
type color = 'white' | 'black' | (string & {});
CodePudding user response:
The 'string' type not working as expected in typescript with union types. You should make it 'String' rather than 'string' and it will work I think.
type color = 'white' | 'black' | String;


