type fs = "a" | 'fssa' | 'fc';
interface f {
s: {
[P in fs]: { type: number; border: string };
f: string;
};
}
报错 映射的类型可能不声明属性或方法。ts(7061)
大佬们想问下 为何写了 P in fs 这一行后 在写其他类型报错? 应该如何简写?
大佬们 想问下 这个 为何这样写就报错了 → 也是 映射的类型可能不声明属性或方法。ts(7061)
type fs = "a" | 'fssa' | 'fc';
interface f {
[P in fs]: { type: number; border: string };
}
使用交叉类型 intersection , https://www.typescriptlang.or...