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

Error: did not recognize object of type "TSInstantiationExpression" #1230

Closed
Arooba-git opened this issue Nov 24, 2022 · 9 comments · Fixed by #1232
Closed

Error: did not recognize object of type "TSInstantiationExpression" #1230

Arooba-git opened this issue Nov 24, 2022 · 9 comments · Fixed by #1232

Comments

@Arooba-git
Copy link

Arooba-git commented Nov 24, 2022

Hi 👋
I'm using recast with babel parser, and getting this error when trying to parse any file containing TSInstantiationExpression. Is recast missing TSInstantiationExpression support or am I missing something? 🤔

Screen Shot 2022-11-22 at 6 15 55 AM

@Arooba-git
Copy link
Author

bump

eventualbuddha added a commit that referenced this issue Nov 25, 2022
Refs #1230

See https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#instantiation-expressions. This won't work yet because `ast-types` does not yet know about `TSInstantiationExpression`. Once it does `recast` will need to be updated to include the newer release of `ast-types`, at which point it will be supported.
@eventualbuddha eventualbuddha linked a pull request Nov 25, 2022 that will close this issue
@iliakan
Copy link

iliakan commented Dec 9, 2022

Is there any workaround or a temporary fix for that? I'd be happy to ignore these, just not to die.

My jscodeshift-based auto-refactoring script fails to work on real-life files because of that. Even though it doesn't need to refactor any TSInstantiationExpressions.

@eventualbuddha
Copy link
Collaborator

Does it fail on every file? Or only files with TSInstantiationExpressions? You could comment them out for now.

@iliakan
Copy link

iliakan commented Dec 9, 2022

I have a large codebase, 100+ files have TSInstantiationExpressions. The refactoring script fails on them.

benjamn pushed a commit that referenced this issue Dec 11, 2022
Refs #1230

See https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#instantiation-expressions.

This won't work yet because `ast-types` does not yet know about
`TSInstantiationExpression`. Once it does `recast` will need to be
updated to include the newer release of `ast-types`, at which point it
will be supported.
@iliakan
Copy link

iliakan commented Dec 12, 2022

Without any type of pressure, may I kindly wonder, is this going to be fixed soon?

I saw a commit has landed, but not sure how much work is ahead.

Thank you for what you do!

@benjamn
Copy link
Owner

benjamn commented Dec 13, 2022

The remaining work in #1232 is worthwhile for completeness but not necessarily relevant unless you're using ClassAccessorProperty (a very new AST node type).

@iliakan If you want to test the current changes locally, you should be able to run this command to install recast@0.23.0-pr1232.0:

npm i recast@pr-1232

If this is useful, let me know. I might try to automate it for any PR, so it's easier for folks to test/use any proposed changes.

@eventualbuddha
Copy link
Collaborator

I've updated the pr-1232 tag with the latest from #1232. Working for you, @iliakan?

@iliakan
Copy link

iliakan commented Dec 14, 2022

Last time it worked without errors (but I did not check the outcome). I'll retest again after I rewrite some stuff ;)

@benjamn
Copy link
Owner

benjamn commented Dec 14, 2022

Alright folks, please try running npm i recast@next to get version 0.23.1, which includes support for TSInstantiationExpression and some other AST types that were lagging behind Babel.

Since I have not tagged this version as latest on npm yet, we can still fix bugs relatively easily, if you encounter anything strange after updating.

coderaiser pushed a commit to coderaiser/recast that referenced this issue May 27, 2024
Refs benjamn#1230

See https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/#instantiation-expressions.

This won't work yet because `ast-types` does not yet know about
`TSInstantiationExpression`. Once it does `recast` will need to be
updated to include the newer release of `ast-types`, at which point it
will be supported.
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

Successfully merging a pull request may close this issue.

4 participants