[Fixed] Is there a way to get the type of an uninitialised variable in Typescript?


I have a variable a declared with type string, but uninitialised. Is there a way to get the string type instead of an undefined?

> let a:string;
> console.log(typeof a);


yes, there is a way to get types metadata in typescript, but you would have to activate reflect metadata option in typescript compiler config and import reflect metadata polyfill, which will increase you bundle size.

look here to find more suitable example of accessing typescript types.

Leave a Reply

(*) Required, Your email will not be published