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的类型是否正确,其它属性不错检测
posted @ 2018-10-19 22:19  Ajanuw  阅读(484)  评论(0编辑  收藏  举报