1

Lets assume I have:

type Channels = 'Main' | 'Secondary' | 'Misc'
var argChannel: string = 'Main'

How do i check if argChannel is a valid Channel in typescript?

Typescript does not allow direct comparison as it will report 'Channels' only refers to a type, but is being used as a value here.

Enzin
  • 11
  • 1
  • @lusc That definitely made me rethink my code structure and export both the string array aswell as the type, using the array for comparisons as done in the example you sent. Problem solved, thank you! – Enzin Mar 08 '23 at 20:51

0 Answers0