简体   繁体   中英

TS2304 TypeScript (TS) Cannot find name

I am getting this error about Cannot find name 'Record' is that a package I need to install for this class?

Severity Code Description File Project Line Suppression State Error TS2304 (TS) Cannot find name 'Record'. C:\WebProjects\ITF\node_modules\orderedmap\types\index.d.ts C:\WebProjects\ITF\Web (tsconfig or jsconfig project) 29 Active

在此处输入图像描述

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 is a Utility Type which was added in 2.1

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

So by checking your Version you might consider updating.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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