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

Esbuild loader Cannot read enum property #85

Closed
olegKusov opened this issue Dec 20, 2020 · 1 comment · Fixed by #97
Closed

Esbuild loader Cannot read enum property #85

olegKusov opened this issue Dec 20, 2020 · 1 comment · Fixed by #97

Comments

@olegKusov
Copy link

olegKusov commented Dec 20, 2020

Can't properly configure webpack with esbuild-loader. I'm getting error in enum.

Cannot read property 'MyProperty' of undefined.

enum MyProperty {
  SomeEnum = 'screen_history',
}

const history = MyProperty.SomeEnum;

My webpack config:

{
        test: /\.js$/,
        loader: 'esbuild-loader',
        options: {
          target: 'es2015',
        },
      },
      {
        test: /\.jsx$/,
        loader: 'esbuild-loader',
        options: {
          loader: 'jsx',
          target: 'es2015',
        },
      },
      {
        test: /\.tsx$/,
        loader: 'esbuild-loader',
        options: {
          loader: 'tsx',
          target: 'es2015',
          tsconfigRaw: require('./tsconfig.json'),
        },
      },
      {
        test: /\.ts$/,
        loader: 'esbuild-loader',
        options: {
          loader: 'ts',
          target: 'es2015',
          tsconfigRaw: require('./tsconfig.json'),
        },
      },


@olegKusov olegKusov changed the title Esbuild loader Esbuild loader Cannot read enum property Dec 20, 2020
@privatenumber
Copy link
Owner

I added a test-case in #97 to demonstrate that TypeScript enums compile fine. Check out the test fixture here for a reference.

It seems your error is about something else since it reads:

Cannot read property 'MyProperty' of undefined.

So it seems you're trying to read the property MyProperty of some other variable.

If you're still running into this, send me a link to a minimal reproduction repo and I can take a look.

@privatenumber privatenumber linked a pull request Jan 21, 2021 that will close this issue
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.

2 participants