ts 索引签名 无视多余的属性类型
interface SquareConfig {
color?: string;
width?: number;
[propName: string]: any;
}
function asd(opt: SquareConfig): any {
}
asd({color: 'red', width: 2, name: 'asd', age: 14}) // 只关心 color和width的类型是否正确,其它属性不错检测
interface SquareConfig {
color?: string;
width?: number;
[propName: string]: any;
}
function asd(opt: SquareConfig): any {
}
asd({color: 'red', width: 2, name: 'asd', age: 14}) // 只关心 color和width的类型是否正确,其它属性不错检测