📅  最后修改于: 2022-03-11 14:48:36.098000             🧑  作者: Mango
// This defines an interface that only allows values to be numbers
interface INumbersOnly {
[key: string]: number;
}
// when using it, it will check that all properties are numbers
var x: INumbersOnly = {
num: 1, // works fine
str: 'x' // will give a type error
};