【发布时间】:2018-06-24 00:26:43
【问题描述】:
如果我们像这样定义一个装饰器函数:
return function IsDefined(object: any, propertyName: string) {
....
]
然后像这样装饰一些属性:
class Test {
@IsDefined() p1: String = "";
}
并在装饰器内部执行这个测试:
expect(object).to.equal(Test);
应该通过吗?什么是object?
这个例子通过:
const instance:any = new Test();
expect(object.constructor.name).
to.equal(instance.constructor.name);
【问题讨论】:
标签: javascript typescript mocha.js chai typescript-decorator