0
我有一个非常简单的类,如:类型错误:不是一个函数打字稿
export class Party {
constructor(
public id:Identifier,
public partyName: PartyName,
public person:Person
) { }
copy():Party {
let copyParty = new Party(this.id, null, null);
return copyParty;
}
}
我想在另一个类(具体服务)使用拷贝功能(或方法?)导入这个类,如:
... (party => {
let copyParty:Party = party.copy();
...
,但我得到以下异常:
EXCEPTION: Uncaught (in promise): TypeError: party.copy is not a function
我试过let copyParty:Party = Function.call(party.copy, copy)
(有一些例外)以及let copyParty:Party = party.copy;
(返回函数定义,而不是复制的对象)。
我在这里错过了什么? 谢谢。
我的猜测是,'party'你,是不是实例化'Party'对象。它从何而来? – PierreDuc
如果你输入你的参数'(party:Party =>)'它将帮助你追踪为什么一个party对象没有被传入。 –
@PierreDuc'party'实例通过'.then(res => res.json()作为Party [])[0])的一个REST调用块 – suat