admin管理员组文章数量:1023738
I am implementing a DI container for my framework in typescript, and want to know my class constructor parameters and properties for instantiating. Here is an example:
interface IDriver
{
Drive(): void
}
class DriverA implements IDriver
{
public Tickets: Array<Ticket>;
public Name: String;
public Drive() {
//Driving...
}
}
I am passing the interface name IDriver as string (because I was not able to pass the interface as a parameter) and concrete class DriverA to my registration routine. Latter in resolving state, to instantiate DriverA, I got the constructor and the Drive method, but I can't find the properties such as Tickets and Name. How can I access those properties? is it possible?
I am implementing a DI container for my framework in typescript, and want to know my class constructor parameters and properties for instantiating. Here is an example:
interface IDriver
{
Drive(): void
}
class DriverA implements IDriver
{
public Tickets: Array<Ticket>;
public Name: String;
public Drive() {
//Driving...
}
}
I am passing the interface name IDriver as string (because I was not able to pass the interface as a parameter) and concrete class DriverA to my registration routine. Latter in resolving state, to instantiate DriverA, I got the constructor and the Drive method, but I can't find the properties such as Tickets and Name. How can I access those properties? is it possible?
Share Improve this question asked Dec 12, 2013 at 1:56 yalemyalem 11 silver badge3 bronze badges1 Answer
Reset to default 4Properties are only available if you initialize them e.g:
class DriverA
{
public Tickets = [];
public Name = "";
public Drive() {
//Driving...
}
}
will generate :
var DriverA = (function () {
function DriverA() {
this.Tickets = [];
this.Name = "";
}
DriverA.prototype.Drive = function () {
//Driving...
};
return DriverA;
})();
Notice this.Tickets
. PS: they only get added after the constructor is called. i.e new DriverA()
I am implementing a DI container for my framework in typescript, and want to know my class constructor parameters and properties for instantiating. Here is an example:
interface IDriver
{
Drive(): void
}
class DriverA implements IDriver
{
public Tickets: Array<Ticket>;
public Name: String;
public Drive() {
//Driving...
}
}
I am passing the interface name IDriver as string (because I was not able to pass the interface as a parameter) and concrete class DriverA to my registration routine. Latter in resolving state, to instantiate DriverA, I got the constructor and the Drive method, but I can't find the properties such as Tickets and Name. How can I access those properties? is it possible?
I am implementing a DI container for my framework in typescript, and want to know my class constructor parameters and properties for instantiating. Here is an example:
interface IDriver
{
Drive(): void
}
class DriverA implements IDriver
{
public Tickets: Array<Ticket>;
public Name: String;
public Drive() {
//Driving...
}
}
I am passing the interface name IDriver as string (because I was not able to pass the interface as a parameter) and concrete class DriverA to my registration routine. Latter in resolving state, to instantiate DriverA, I got the constructor and the Drive method, but I can't find the properties such as Tickets and Name. How can I access those properties? is it possible?
Share Improve this question asked Dec 12, 2013 at 1:56 yalemyalem 11 silver badge3 bronze badges1 Answer
Reset to default 4Properties are only available if you initialize them e.g:
class DriverA
{
public Tickets = [];
public Name = "";
public Drive() {
//Driving...
}
}
will generate :
var DriverA = (function () {
function DriverA() {
this.Tickets = [];
this.Name = "";
}
DriverA.prototype.Drive = function () {
//Driving...
};
return DriverA;
})();
Notice this.Tickets
. PS: they only get added after the constructor is called. i.e new DriverA()
本文标签:
版权声明:本文标题:javascript - how can I access typescript class public property at run time (debugging)? only the constructor and functions are a 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745542472a2155244.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论