【问题标题】:Supplied parameters do not match any signature of call target提供的参数与调用目标的任何签名都不匹配
【发布时间】:2016-06-09 02:21:18
【问题描述】:

当我在方法中使用参数装饰器时出现此构建错误。该类实现了一个接口。下面是接口和类:

export interface IClient{
    getServerConfig(): Observable<Response> ;

    getDashboard(): Observable<Response>;

    deploy(channelId: string): Observable<Response>;
}

export class Client implements IClient {

    public constructor( @Inject(Http) private http: Http, @Inject(Model) private config: Model) {
        super(http, config);
    }

    public getServerConfig(): Observable<Response> {
        return null;
    }

    public getDashboard(): Observable<Response> {
        return null;
    }

    public deploy(@Body('param') channelId: string): Observable<Response> {
        return null;
    }
}

构建时出现此错误

Supplied parameters do not match any signature of call target.

就在部署函数处。

问题似乎是channelId参数旁边的参数装饰器。现在我不能在需要时删除它,所以我想知道是否有办法保留接口定义和装饰器。接口中不允许使用装饰器,因此这不是一个选项。

有什么想法吗?

【问题讨论】:

    标签: typescript angular


    【解决方案1】:

    提供的参数与调用目标的任何签名都不匹配。

    最快的解决方法是使用const BodyAny:any = Body 并使用BodyAny。否则修复Body的类型定义。

    【讨论】:

    • 谢谢,您为我指明了正确的方向。我忽略了装饰器的一个参数。
    【解决方案2】:

    我遇到了同样的错误,问题是它所抱怨的服务缺少@Injectable()

    只需导入和添加装饰器就搞定了!

    【讨论】:

      猜你喜欢
      • 2017-04-28
      • 2017-08-24
      • 2017-02-25
      • 2017-07-26
      • 2018-03-31
      • 2017-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多