我有以下接口:
interface Ixy
{
X: string;
Y: string;
}
interface Ixz
{
X: string;
Z: string;
}
这个功能:
export function update(json: Ixy) {
var a = json.X;
}
从以下两个地方调用该函数:
export function update1(json: Ixy) {
update(json);
}
export function update2(json: Ixz) {
update(json);
}
有人可以向我解释我可以使用打字稿进行这项工作的最佳方式吗?现在 update1 没问题,但 update2 显示签名不匹配。是我可以解决此问题以将 json 的类型更改为任何类型的唯一方法,还是有更好的方法来做到这一点?