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

class static field is transformed even thou platform sets to 'esnext' when bundle #1524

Closed
hardfist opened this issue Aug 16, 2021 · 2 comments · Fixed by #3167
Closed

class static field is transformed even thou platform sets to 'esnext' when bundle #1524

hardfist opened this issue Aug 16, 2021 · 2 comments · Fixed by #3167

Comments

@hardfist
Copy link
Contributor

hardfist commented Aug 16, 2021

→  ts-demo esbuild src/index.js
class A {
  static a = 1;
}
const a = new A();

→  ts-demo esbuild src/index.js --bundle
(() => {
  var __defProp = Object.defineProperty;
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
  var __publicField = (obj, key, value) => {
    __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
    return value;
  };

  // src/index.js
  var A = class {
  };
  __publicField(A, "a", 1);
  var a = new A();
})();
@hyrious
Copy link

hyrious commented Aug 16, 2021

It may be caused by your tsconfig.json.
maybe related #1480 #1418 (comment) as I bisected that 0.11.7 introduces such lowering.

@snuup
Copy link

snuup commented Jun 9, 2023

This is a serious problem, will this fixed sometime? Is there a workaround.

I can avoid "var __defNormalProp" code with target="2021". But with targets "2022" or "esnet" they are in.
Using target 2021 creates other backwards compatibiltiy transformations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants