当前位置:   article > 正文

A mapped type may not declare properties or methods in TS

a mapped type may not declare properties or methods
enum EmailStatus {
  Read = 'READ',
  Unread = 'UNREAD',
  Draft = 'DRAFT',
}

interface Status  {
  // ⛔️ Error: A mapped type may not declare properties or methods.ts(7061)
  [key in EmailStatus]: string;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

改用 type

enum EmailStatus {
  Read = 'READ',
  Unread = 'UNREAD',
  Draft = 'DRAFT',
}

// 声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签