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

this inside React.createElement outputs an warning #2557

Closed
sapphi-red opened this issue Sep 18, 2022 · 3 comments
Closed

this inside React.createElement outputs an warning #2557

sapphi-red opened this issue Sep 18, 2022 · 3 comments

Comments

@sapphi-red
Copy link
Contributor

When a code transpiled from JSX by babel like

const Foo = () => _jsxDEV(
  "div",
  {},
  void 0,
  false,
  { fileName: "Foo.tsx", lineNumber: 1, columnNumber: 23 },
  this
);

is passed to esbuild, it does not output any warnings. (0905d85)

But when

const Foo = () => {
  return /*#__PURE__*/ _createElement('div', {
    key: null,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 2,
      columnNumber: 10,
    },
  });
};

is passed (this is generated in the same situation with #2534), it outputs a warning (this-is-undefined-in-esm).
stackblitz reproduction

I expect this warning to be omitted, since the _jsxDEV one is already omitted.

related: vitejs/vite#10098

@bathos
Copy link

bathos commented Sep 18, 2022

I’m not sure if it merits a warning or not (would lean towards no), but “since the _jsxDEV one is already omitted” seems unrelated? _jsxDEV is a binding identifier and could have any value / may or may not have been declared in the global obj env or the global lexical env. this is a keyword which is statically known to be undefined in this context.

@evanw
Copy link
Owner

evanw commented Sep 18, 2022

Ok. I will remove the warning.

@evanw evanw closed this as completed in 93e068d Sep 18, 2022
@sapphi-red
Copy link
Contributor Author

Thanks!

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

No branches or pull requests

3 participants