0
这是我喜欢的类型定义代码:为什么不能使用某些领域和keyof在类型定义
interface Foo {
a: string;
b: number;
c: boolean;
}
type Bar = {
[prop in keyof Foo]?: number | string;
};
type Bar2 = {
id: string;
[prop in keyof Foo]?: number | string;
};
与Bar
定义是好的,但也有一些是错误的Bar2
,有没有什么办法来解决这个 ?