What version of TypeScript are you using?
^2.8.3
What version of typescript-eslint-parser are you using?
^15.0.0
What code were you trying to parse?
export const somes = <T>(options: ReadonlyArray<Option<T>>): ReadonlyArray<T> =>
options.filter(isSome).map(o => o.value)
What did you expect to happen?
There not to be a parse error
What happened?
Eslint reported Parsing error: Identifier expected on Option<T>:
export const somes = <T>(options: ReadonlyArray<Option<T>>): ReadonlyArray<T> =>
^^^^^^^^^
options.filter(isSome).map(o => o.value)
Changing this to a function statement instead of a arrow function removes the parse error.
These are both valid:
export const somes = function<T>(options: ReadonlyArray<Option<T>>): ReadonlyArray<T> {
return options.filter(isSome).map(o => o.value)
}
export function somes<T>(options: ReadonlyArray<Option<T>>): ReadonlyArray<T> {
return options.filter(isSome).map(o => o.value)
}
Additionally, removing the type from the parameter changes the error to JSX element 'T' has no corresponding closing tag on the return type ReadonlyArray<T>:
export const somes = <T>(options: Option<T>[]): ReadonlyArray<T> =>
^^^^^^^^^^^^^^
options.filter(isSome).map(o => o.value)
This is not a .tsx file, so the parser should probably not be attempting to parse types as JSX tags