繁体   English   中英

TS2304 TypeScript (TS) 找不到名称

[英]TS2304 TypeScript (TS) Cannot find name

我收到有关Cannot find name 'Record'错误是我需要为此 class 安装 package 吗?

严重性代码说明文件项目行抑制 State 错误 TS2304 (TS) 找不到名称“记录”。 C:\WebProjects\ITF\node_modules\orderedmap\types\index.d.ts C:\WebProjects\ITF\Web(tsconfig 或 jsconfig 项目)29 活动

在此处输入图像描述

declare class OrderedMap<T = any> {
  private constructor(content: Array<string | T>)

  get(key: string): T | undefined

  update(key: string, value: T, newKey?: string): OrderedMap<T>

  remove(key: string): OrderedMap<T>

  addToStart(key: string, value: T): OrderedMap<T>

  addToEnd(key: string, value: T): OrderedMap<T>

  addBefore(place: string, key: string, value: T): OrderedMap<T>

  forEach(fn: (key: string, value: T) => any): void

  prepend(map: MapLike<T>): OrderedMap<T>

  append(map: MapLike<T>): OrderedMap<T>

  subtract(map: MapLike<T>): OrderedMap<T>

  readonly size: number

  static from<T>(map: MapLike<T>): OrderedMap<T>
}

type MapLike<T = any> = Record<string, T> | OrderedMap<T>

export = OrderedMap

Record 是 2.1 中添加的 Utility Type

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#partial-readonly-record-and-pick

因此,通过检查您的版本,您可能会考虑更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM