Is it possible to use variable values as one of the union types in Typescript?
<p>I'm trying to achieve something like this example in Typescript:</p>

<pre><code>const appleOption:string = 'Apple';
const orangeOption:string = 'Orange';

export type FruitType = appleOption | orangeOption   //the compiler wouldn't allow this.

//my intention is for writing of the type be in variable and not their actual strings so that it's easier for me to refactor them in future
const eventType:FruitType = orangeOption; 
</code></pre>

<p>Instead of typing out the union types as literal strings for <code>FruitType</code>, I'm hoping to use variables so that when I need to use the value again, I don't have to rewrite them out as magic strings, but as variables which I can refactor easily at a later time. I was trying to see if I could have an alternative to numeric enums in Typescript.</p>

<p>Is it possible to make use of a variable's value as one of the union type options?</p>