Javascript 财产';平面';类型上不存在

Javascript 财产';平面';类型上不存在,javascript,typescript,Javascript,Typescript,我试图在typescript脚本中使用flat()。我的tsconfig.json中的目标设置为es2017,我为输入变量定义了一个接口。 但是我确实得到了错误属性“flat”在类型“{type:string;source:string;target:string;}[][]”上不存在。 有人能解释一下为什么会出现这个问题吗 interface Dependencies { [key: string]: Array<{ type: string source: stri

我试图在typescript脚本中使用
flat()
。我的tsconfig.json中的目标设置为
es2017
,我为输入变量定义了一个接口。 但是我确实得到了错误
属性“flat”在类型“{type:string;source:string;target:string;}[][]”上不存在。

有人能解释一下为什么会出现这个问题吗

interface Dependencies {
  [key: string]: Array<{
    type: string
    source: string
    target: string
  }>
}
function example(deps: Dependencies) {
  const result = Object
    .values(deps) // Property 'flat' does not exist on type '{ type: string; source: string; target: string; }[][]'
    .flat()

  return result
}
const dependencies = {
  'foo': [
    {
      type: 'static',
      source: 'source',
      target: 'target'
    }
  ]
}
example(dependencies)
接口依赖项{
[键:字符串]:数组
}
函数示例(deps:依赖项){
常量结果=对象
.values(deps)//类型{type:string;source:string;target:string;}[][]上不存在属性“flat”
.flat()
返回结果
}
常量依赖项={
“福”:[
{
类型:“静态”,
来源:'来源',
目标:“目标”
}
]
}
示例(依赖项)

扁平
在ES2019中添加



flat
是在
ES2019
中添加的,我更改了编译器选项
“target:“ES2019”
,但仍然是相同的错误我在将目标更改为ES2019后遇到了相同的问题,我重新构建了我的应用程序,错误消失了目标
ES2019的工作示例