首页 > 解决方案 > 仅在界面中使用 Record 而不是 TypeScript 中的动态键

问题描述

type我可以写两种方式:

  1. type someType = {[key: string]: any}
  2. type someType = Record<string, any>

我想对interfacebu 做同样的事情,而不是:interface someInter {[key: string]: any}我希望能够做类似的事情:interface someInter Record<string, any>..

有可能吗?以任何方式?

标签: javascripttypescript

解决方案


推荐阅读