Currently, I am in the process of converting the below code snippet from Flow to TypeScript
let headAndLines = headerAndRemainingLines(lines, spaceCountToTab),
header: string[] = headAndLines.header,
groups: string[][]= headAndLines.groups,
arrToObjs: (string[]) => {[string]: any}[] = makeArrayToObjectsFunction(errorInfo, spaceCountToTab, header),
....
TS is showing an error regarding the lambda type of arrToObjs.
Unexpected token, expected ";" (361:28)
359 | header: string[] = headAndLines.header,
360 | groups: string[][]= headAndLines.groups,
361 | arrToObjs: (string[]) => {[string]: any}[] = makeArrayToObjectsFunction(errorInfo, spaceCountToTab, header),
I have attempted to enclose the entire expression in brackets
(string[]) => {[string]: any}[])
however, that has not resolved the issue.
arrToObjs
represents a function that accepts an array of strings and outputs an array of maps containing {string: any}
. Can you advise on the correct way to define this type signature in TypeScript?