-
Notifications
You must be signed in to change notification settings - Fork 47k
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: Components inside typescript namespaces cause ReferenceError #22413
Comments
To add more details, namespace with a capitalized function member is transformed into this piece of code:
The error occurs in vite's development mode since the application code is imported via |
cc @gaearon To confirm if this is a known/expected limitation. |
I have also encountered this error using Vite & react-refresh on a TypeScript react app that has react components nested under namespaces |
This comment has been minimized.
This comment has been minimized.
No, it's not expected. This seems like a bug in the transform. Transform: https://github.com/facebook/react/blob/main/packages/react-refresh/src/ReactFreshBabelPlugin.js Tests:
If somebody wants to take this one, the first step is to produce a failing integration test demonstrating the issue. (Using compiled TS output as the "source" is fine.) |
@gaearon I see that no one has started work on this issue, I'll have a crack at this. |
@owen-kosman @gaearon I digged in a little bit into this issue and it looks like it only happends when code with I manage to fix it but I haven't add any tests because of issue mentioned above. If it's fine here is PR #22601 |
@ideffix Hi I think your fix does not solve the real problem here. I digged a little more and found that in this specific babel config in this issue.
this line of code gives a false assumption.
It seems babel parses namespace syntax into a structure with So I think the fix should be related, i'm not familiar with babel parser and not sure the best way to fix this, but hope the info helps. |
Should be fixed in |
Forwarded from vitejs/vite#3900 by @not-rusty based on the recommendation of @sodatea, which stated that this should be considered as a bug in the
react-refresh
package.Describe the bug
Apparently components inside namespaces is not supported. I don't exactly know if the error comes from esbuild or something, but it would nice.
The bug is that is not shown as a compilation error.
Reproduction
Simply start a
react-ts
project with$ npm init @vitejs/app my-vue-app --template react-ts
and write the following code:System Info
Used package manager: npm
Logs
I get the following runtime error:
I suppose it should be a compilation error?
The text was updated successfully, but these errors were encountered: