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

4x4 Matrix in Python -

python - String indices must be integers and while issue -

wso2is - WSO2 IS 5.0.0 SP1 After restart there is authentication error -