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
[Bug]: You gave us a visitor for the node type TSInstantiationExpression but it's not a valid type #14587
Comments
Hey @ngregory-rbi! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite. |
Do you have a complete stack trace? As a workaround, delete |
I don't, but if I recall it originated in my main file, so not much of a stack to speak of. And this issue started happening after removing |
Also, it would help if you can share the versions of the various Babel packages present in your lockfile. |
I just deleted both |
Ok this did resolve the issue. It appears you were correct that my |
I'm glad that it works now! |
Hello, @nicolo-ribaudo I too encountered the same error when building. I suspect the problem is that the latest version of Here are the branches we used for verification https://github.com/cateiru/babel-preset-ts-error yarn create next-app --typescript .
yarn add --dev jest
yarn add --dev babel-jest @babel/core @babel/preset-env
yarn add --dev @babel/preset-typescript
touch babel.config.js
vi babel.config.js // edit: https://jestjs.io/docs/getting-started#using-typescript ~/r/babel-preset-ts-error » yarn build main ✗
yarn run v1.22.18
$ next build
info - Checking validity of types
info - Disabled SWC as replacement for Babel because of custom Babel configuration "babel.config.js" https://nextjs.org/docs/messages/swc-disabled
info - Using external babel configuration from /home/user/repositories/babel-preset-ts-error/babel.config.js
info - Creating an optimized production build
Failed to compile.
./pages/_app.tsx
Error: [BABEL] /home/user/repositories/babel-preset-ts-error/pages/_app.tsx: You gave us a visitor for the node type TSInstantiationExpression but it's not a valid type
at verify (/home/name/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1890:372053)
at Function.explode (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1890:370915)
at /home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2774429
at Generator.next (<anonymous>)
at Function.<anonymous> (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2804218)
at Generator.next (<anonymous>)
at evaluateSync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2727582)
at Function.sync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2725598)
at sync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2804714)
at sync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2726915)
./pages/index.tsx
Error: [BABEL] /home/user/repositories/babel-preset-ts-error/pages/index.tsx: You gave us a visitor for the node type TSInstantiationExpression but it's not a valid type
at verify (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1890:372053)
at Function.explode (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1890:370915)
at /home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2774429
at Generator.next (<anonymous>)
at Function.<anonymous> (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2804218)
at Generator.next (<anonymous>)
at evaluateSync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2727582)
at Function.sync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2725598)
at sync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2804714)
at sync (/home/user/repositories/babel-preset-ts-error/node_modules/next/dist/compiled/babel/bundle.js:1:2726915)
> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. |
Thanks for the reproduction! The lockfile versions look correct, so this is indeed a bug. I'll try to work on a fix later today! |
What I have found so far: even if your lockfile says (However, everything should work with the old version. I'm still investigating). |
Sorry, what is the workaround? |
So far the only workaround is to make sure that you are using a 7.17.x version of |
Thanks, Nicolo. By forcing use of @babel/core and @babel/plugin-transfor-typescript to version '7.17.12' and re-creating my dependencies, I don't have this problem anymore! |
We released 7.18.4 of the TS plugin which should properly fix this. Could you check if it works? 🙏 |
I chaged the version of the plugin-transfor-typescript package to 7.18.4 and it works fine, but previously I wasn't specifying this package in my dependencies explicitly. Babel/core still using 7.17.12. I guess you will need to port the fix there. |
You can probably now remove it from your dependencies, the only problem is that your lockfile contained an older version of the plugin. |
Hi! @nicolo-ribaudo Sorry for the delay in replying. Thank you for your quick response 🙇 |
💻
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, ...)
Input code
N/A. This is run through Metro Bundler (the bundler for React Native).
Configuration file name
babel.config.js
Configuration
Note: this is a compiled config.
Current and expected behavior
The Metro bundler successfully bundles my app.
Environment
N/A
Possible solution
Look at what is missing in the implementation of #14322 .
Additional context
This change seems to be related to Babe v7.18.0 (or thereabouts).
Here is a StackOverflow question having this issue: https://stackoverflow.com/questions/72328356/
And here are some other GitHub issues in some other projects:
vercel/next.js#37080
umijs/dumi#1093
It appears #14322 was not implemented properly.
Due to the complicated nature of my app, it appears it will difficult to simply revert my Babel version, as it is required upstream with many different versions. A fix is urgently needed.
The text was updated successfully, but these errors were encountered: