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
I'd like to append two const string literal values together and extract or assign a new string literal type.
Sorry if this is a duplicate of something, I couldn't find an existing issue.
TypeScript Version: 2.4.2 / PlayGround
Code
constAPPLE='APPLE';constPINEAPPLE='PINEAPPLE'typeAppleLiteralType='APPLE'constAPPLE2: AppleLiteralType=APPLE// this is only `string`,// even though it's two literals appendedconstAPPLEPINEAPPLE=APPLE+PINEAPPLE;// Type 'string' is not assignable to type '"APPLEPINEAPPLE"'.constTest: 'APPLEPINEAPPLE'=APPLE+PINEAPPLE;constTest2: 'APPLEPINEAPPLE'=`${APPLE}${PINEAPPLE}`;
Expected behavior: Test and/or Test2 should work with the `'APPLEPINEAPPLE' string literal type
Actual behavior: Test and Test2 both turn into string types
The text was updated successfully, but these errors were encountered:
I'd like to append two
const
string literal values together and extract or assign a new string literal type.Sorry if this is a duplicate of something, I couldn't find an existing issue.
TypeScript Version: 2.4.2 / PlayGround
Code
Expected behavior:
Test
and/orTest2
should work with the `'APPLEPINEAPPLE' string literal typeActual behavior:
Test
andTest2
both turn intostring
typesThe text was updated successfully, but these errors were encountered: