具有lib和目标集的类型“ ObjectConstructor”上不存在属性“ entries”

时间:2019-05-13 12:16:58

标签: javascript angular typescript es2018

我正在尝试使用通过JSON解析的Map:

Object.entries((JSON.parse(variables)))

编译器抛出错误

Property 'entries' does not exist on type 'ObjectConstructor' 

但是该方法有效,我能够检索我的地图。我寻找了其他问题,并更改了tsconfig文件中的target和lib。在tsconfig.app.json内部,我有:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2017",
    "target": "ESNext",
    "baseUrl": "",
    "types": [
      "node"
    ],
    "lib": [
      "es2018",
      "dom"
  ]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

tsconfig.spec.json中的

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
    "module": "commonjs",
    "target": "ESNext",
    "baseUrl": "",
    "types": [
      "jasmine",
      "node"
    ],
    "lib": [
      "es2018",
      "dom"
  ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

我认为设置目标和lib就足够了,但是它仍然无法正常工作。要消除编译器错误还要更改什么?

0 个答案:

没有答案