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

python - RuntimeError: can't re-enter readline -

python - PyInstaller UAC not working in onefile mode -

ios - Pass NSDictionary from Javascript to Objective-c in JavascriptCore -