Typescript: object with at least one property of type T

前端 未结 2 1247
陌清茗
陌清茗 2020-12-11 21:13

How can I write HasNumber without typescript giving me an error because on HasNumberAndString name is not a number? I want a way to en

2条回答
  •  半阙折子戏
    2020-12-11 21:31

    There is no great way in TypeScript to allow a type with an index signature to have an additional property that doesn't match the index signature type. See microsoft/TypeScript#17867 for the suggestion to allow exceptions to index signatures, and maybe give it a

提交回复
热议问题