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

Components inside typescript namespaces #3900

Closed
6 tasks done
alarbada opened this issue Jun 22, 2021 · 3 comments
Closed
6 tasks done

Components inside typescript namespaces #3900

alarbada opened this issue Jun 22, 2021 · 3 comments
Labels
bug: upstream Bug in a dependency of Vite

Comments

@alarbada
Copy link

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:

namespace Lol {
  export const Lol = () => {
    return (
      <div>
        <p>Some component</p>
      </div>
    );
  };
}

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <Lol.Lol />
        <p>Hello Vite + React!</p>
      </header>
    </div>
  );
}

export default App;

System Info

  System:
    OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
    Memory: 440.54 MB / 7.47 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.16.0 - /usr/local/bin/node
    npm: 6.14.13 - /usr/local/bin/npm
  Browsers:
    Chrome: 90.0.4430.93
    Firefox: 89.0.1

Used package manager: npm

Logs

I get the following runtime error:

App.tsx:13 Uncaught ReferenceError: _c is not defined
    at App.tsx:13
    at App.tsx:14

I suppose it should be a compilation error?


Before submitting the issue, please make sure you do the following

@haoqunjiang
Copy link
Member

Can be reproduced with the following babel config:

module.exports = {
  parserOpts: {
    plugins: ['jsx', 'typescript']
  },
  plugins: [
    [require('react-refresh/babel')]
  ]
}

I think it should be considered as a bug in the react-refresh package. Please report to the react team.

@gaearon
Copy link

gaearon commented Nov 9, 2021

We expect this to be fixed in [email protected]. Please verify. Thanks!

@haoqunjiang
Copy link
Member

I can confirm that this bug no longer exists after bumping react-refresh to '^0.11.0' in #5245
The update will be included in the next @vitejs/plugin-react release.

Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite
Projects
None yet
Development

No branches or pull requests

3 participants