interface SkillProperty {
[name: string] : number
};
let skills: SkillProperty;
skills = {}; // ok
skills = { fire: 123 }; // ok
skills = {
...skills, // ok
...{}, // ok
...extraSkills() // {} | { ice: number } is not assignable to type 'SkillProperty'.
}
function extraSkills() {
if (whatever) {
return {};
}
return { ice: 321 };
}
如何更改我的SkillProperty
界面以使其符合空对象和我的实际 SkillProperty 类型?