Skip to content

Wrong structure of TSFunctionType node #940

@shogunsea

Description

@shogunsea

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:
image

However when using jscodeshift with recast/ast-types it's being parsed as the following:
jscodeshiftCodemod ts — pineapple 2023-07-06 15-43-42

instead of being on the tsFunctionTypeNode.returnType.typeAnnotation attribute, it's actually structured as tsFunctionTypeNode.typeAnnotation.typeAnnotation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions