enums - How to iterate a string literal type in typescript -


how can iterate string literal type in typescript?

for example define type

type name = "bill gates" | "steve jobs" | "linus torvalds"; 

i want iterate this

for (let name of name) {     console.log("possible name: " + name); } 

or not possible in typescript?

since typescript compiler, none of typing information present in runtime. means unfortunately cannot iterate through type.

depending on you're trying possible use enums store indices of names can retrieve in array.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -