【发布时间】:2020-01-30 23:39:03
【问题描述】:
我正在尝试遵循此示例。我无法编译它。关于如何解决问题的任何想法?
import { Component } from '@angular/core';
function log(className)
{
console.log(className)
return (...args) => {
console.log("Arguments passed to this class's constructor are ", args)
return new className(...args)
}
}
@log
class myExampleClass
{
constructor(arg1, arg2)
{
console.log("Constructor fired!")
}
}
const myClass = new myExampleClass(5,10)
我得到的错误是。
Unable to resolve signature of class decorator when called as an expression.
Type '(...args: any[]) => any' is not assignable to type 'typeof myExampleClass'.
Type '(...args: any[]) => any' provides no match for the signature 'new (arg1: any, arg2: any): myExampleClass'.
【问题讨论】:
标签: angular typescript