有没有办法将参数装饰器与 一起使用通天塔 在 中是可能的 typescript .
typescript 代码示例:
class A {
constructor(@Inject('IService') private service: IService) {
}
}
我想用 写这段代码通天塔 :
class A {
constructor(@Inject('IService') service) {
this.service = service;
}
}
我还没有找到关于这个问题的任何信息。在某个预设中是否有类似的插件可以做到这一点?
如果没有拐杖就无法做到这一点,有没有办法在构造函数上使用装饰器?例子
class A {
@Inject('IService')
constructor(service) {
this.service = service;
}
}
谢谢。
最佳答案
Babel does not currently support this feature
您现在有两个选择:
不幸的是,第一个选项在细节上并不完美,如以下示例所示:
@Get('/:id')
getUser(@Param("id") id: number) {
cosnole.log(typeof id); // string
}
关于parameters - 带有 Babel 的参数装饰器(如在 Typescript 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46581307/