fruit.ts に載っているものはこちら
export type Fruit = "Orange" | "Apple" | "Banana"
今、別のTypeScriptファイルにfruit.tsをインポートしています。これが私の持っているものです
myString:string = "Banana";
myFruit:Fruit = myString;
私がする時
myFruit = myString;
エラーが発生します:
タイプ 'string' はタイプ '"Orange" | "Apple" | "Banana"' に割り当てることはできません
カスタム タイプ Fruit の変数に文字列を割り当てるにはどうすればよいですか?