My challenge involves utilizing the flat()
method in a TypeScript script. In my tsconfig.json file, I have set the target to es2017
and defined an interface for the input variable. However, I keep encountering this error message:
Property 'flat' does not exist on type '{ type: string; source: string; target: string; }[][]'
I am curious about the root cause of this issue. Can someone shed some light on why it is happening?
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)