Wrong structure of TSFunctionType node
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 194
- Avg merge
- 22h 43m
- Merged PRs (30d)
- 10
Description
Given the following code:
```
export const FooFoo = buildFoo('Foo') as unknown as (foo: any) => Foo | FooLegacy;
```
What ast-explorer shows is that the `TSUnionType` node is on the `returnType` attribute of the `TSFunctionType` node:

However when using jscodeshift with recast/ast-types it's being parsed as the following:
instead of being on the `tsFunctionTypeNode.returnType.typeAnnotation` attribute, it's actually structured as `tsFunctionTypeNode.typeAnnotation.typeAnnotation`
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the reported TypeScript snippet in ast-explorer and through jscodeshift with recast/ast-types. Compare the TSFunctionType structure, especially returnType and typeAnnotation, and inspect the parser and AST node definitions involved. Done means both paths expose the TSUnionType under the same expected attribute.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100