2016-02-26 67 views
3

我在方法中使用参数装饰器时遇到此构建错误。该类实现一个接口。下面是接口和类:提供的参数不匹配调用目标的任何签名

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参数旁边的参数装饰器。现在我不能随便删除它,所以我想知道是否有一种方法来保持接口定义和装饰器。装饰者不能在界面中使用,因此这不是一个选项。

任何想法?

回答

2

提供的参数不匹配呼叫目标的任何签名。

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

+0

谢谢,你只是指出我在正确的方向。我忽略了装饰器的一个参数。 –

0

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

只需导入并添加装饰器就可以把它整理出来!

相关问题