- Rollup Version: 1.7.0
- Operating System (or Browser): Fedora building for Chrome 72+
- Node Version: 10.15.0
How Do We Reproduce?
Minimum reproduction is at https://github.com/coreyfarrell/rollup-class-fields (I was not able to figure out how to add an acorn parser with REPL). rollup.config.js demonstrates the issue (produces broken.js), rollup.workaround.js shows how I'm dealing with this for now, produces workaround.js. Rollup can be run against both configs using npm install && npm test.
Expected Behavior
The this keyword found anyplace within a class body should not be considered top-level. For static class fields this is the class, for public class fields it refers to the instance.
Actual Behavior
this in the following code gets replaced with undefined:
class Example {
a = 1;
b = this.a + 1;
}
How Do We Reproduce?
Minimum reproduction is at https://github.com/coreyfarrell/rollup-class-fields (I was not able to figure out how to add an acorn parser with REPL).
rollup.config.jsdemonstrates the issue (producesbroken.js),rollup.workaround.jsshows how I'm dealing with this for now, producesworkaround.js. Rollup can be run against both configs usingnpm install && npm test.Expected Behavior
The
thiskeyword found anyplace within a class body should not be considered top-level. For static class fieldsthisis the class, for public class fields it refers to the instance.Actual Behavior
thisin the following code gets replaced withundefined: