ts报错, 该怎么改呢 ?

        type Type1 = {
          a: boolean,
          [x: string]: number
        };
        const type1: Type1 = {
          a: true,
          b: 2,
        };
        console.log('type1:', type1);
阅读 1.7k
2 个回答

image.png

因为Type1定义了任意属性都是number类型,所以Type1里面其他的确定属性和可选属性必须都是number的子集

推荐问题