Typescript Type string is not assignable to type

Mistake producing Gemini contented Question & Answer :

Present’s what I person successful consequence.ts

export kind Consequence = "Orangish" | "Pome" | "Banana" 

Present I’m importing consequence.ts successful different typescript record. Present’s what I person

myString:drawstring = "Banana"; myFruit:Consequence = myString; 

Once I bash

myFruit = myString; 

I acquire an mistake:

Kind ‘drawstring’ is not assignable to kind ‘“Orangish” | “Pome” | “Banana”’

However tin I delegate a drawstring to a adaptable of customized kind Consequence?

Replace

Arsenic talked about successful @Simon_Weaver’s reply, since TypeScript interpretation three.four it’s imaginable to asseverate it to const:

fto consequence = "Banana" arsenic const; 

Aged reply

You’ll demand to formed it:

export kind Consequence = "Orangish" | "Pome" | "Banana"; fto myString: drawstring = "Banana"; fto myFruit: Consequence = myString arsenic Consequence; 

Besides announcement that once utilizing drawstring literals you demand to usage lone 1 |