Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong structure of TSFunctionType node #940

Open
shogunsea opened this issue Jul 6, 2023 · 1 comment
Open

Wrong structure of TSFunctionType node #940

shogunsea opened this issue Jul 6, 2023 · 1 comment

Comments

@shogunsea
Copy link

shogunsea commented Jul 6, 2023

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

@shogunsea
Copy link
Author

additionally, it seems TSFunctionTypeBuilder only takes single parameters argument, so it seems it's impossible to annotate the return type?

parameters: (K.IdentifierKind | K.RestElementKind | K.ArrayPatternKind | K.ObjectPatternKind)[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant