-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
It appears references to already-initialized private static members can get lifted out of the lexical scope where their names exist.
Input
export class Foo {
static #bar = 1;
static baz = Foo.#bar;
}
- version
- 0.11.6
- minify
- false
- format
- esm
- target
- none / esnext / maybe others do it too
Output
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;
};
var _Foo = class {
static #bar;
};
var Foo = _Foo;
Foo.#bar = 1;
__publicField(Foo, "baz", _Foo.#bar);
export {
Foo
};
The condition for this seems to be the presence of a reference to Foo
(or this
) in a static initializer (which may or may not be private). I think it’s the same set of scenarios where it’s altering the value of Foo.name
.
Metadata
Metadata
Assignees
Labels
No labels