How to get the type of a property of an object with Typescript 1.4.0.
I'm searching for something similar to C# it has the possibility to look up the properties of an object.
var properties = typeof(T).GetProperties();
foreach( var property in properties){}
What I have so far is:
var ls = ts.createLanguageService(host, ts.createDocumentRegistry())
var nav = ls.getNavigationBarItems(host.fileName);
Given the example Interface:
interface Example {
firstname: string;
lastname: string;
age: string;
}
The TypeScript language service returns the result:
{
"NavigationBarItems":[
{
"text":"Example",
"kind":"interface",
"kindModifiers":"",
"spans":[
{
"start":0,
"length":83
}
],
"childItems":[
{
"text":"age",
"kind":"property",
"kindModifiers":"",
"spans":[
{
"start":69,
"length":12
}
],
"childItems":[
],
"indent":0,
"bolded":false,
"grayed":false
},
{
"text":"firstname",
"kind":"property",
"kindModifiers":"",
"spans":[
{
"start":24,
"length":18
}
],
"childItems":[
],
"indent":0,
"bolded":false,
"grayed":false
},
{
"text":"lastname",
"kind":"property",
"kindModifiers":"",
"spans":[
{
"start":47,
"length":17
}
],
"childItems":[
],
"indent":0,
"bolded":false,
"grayed":false
}
],
"indent":0,
"bolded":false,
"grayed":false
}
]
}
The information I'm missing is the type (string,number,Map<>,any) and if it is an array or object e.g.
"text":"lastname",
"kind":"property",
"type":"string", //string,number,Map<>,any
Any Idea how to achieve this?
Your help is highly appreciated.