typescript-go
typescript-go copied to clipboard
Parser divergence: Generic arrow function with function return type
const foo = <T>(x: T): (() => T) => {
return () => x;
}
Expected: No error
Actual
foo.ts:1:18 - error TS1005: ')' expected.
1 const foo = <T>(x: T): (() => T) => {
~
foo.ts:1:21 - error TS1005: ',' expected.
1 const foo = <T>(x: T): (() => T) => {
~
foo.ts:1:22 - error TS1134: Variable declaration expected.
1 const foo = <T>(x: T): (() => T) => {
~
foo.ts:1:24 - error TS1134: Variable declaration expected.
1 const foo = <T>(x: T): (() => T) => {
~
foo.ts:1:34 - error TS1005: ';' expected.
1 const foo = <T>(x: T): (() => T) => {
~~
Found 5 errors in the same file, starting at: foo.ts:1
Also occurs when not parenthesized:
const foo = <T>(x: T): () => T => {
return () => x;
}
Hi, I wanted to check if this issue is still relevant. I believe it has been resolved, I tested it myself and found that it no longer occurs in the latest version.
Looks like you're right - thanks @ongyimeng!