💻
How are you using Babel?
babel-loader (webpack)
Input code
Babel REPL
declare class Foo {
static bar;
}
Configuration file name
babel.config.js
Configuration
module.exports = {
compact: false,
presets: [
['@babel/preset-typescript'],
],
plugins: [
'@babel/plugin-proposal-class-properties',
],
}
Current and expected behavior
Current behaviour: (omitting helpers - happens with import-helpers or when they are inline.)
_defineProperty(Foo, "bar", void 0);
Expected behaviour:
// no "defineProperty" for the static class prop
Environment
- System:
- Binaries:
- Node: 16.9.1 - ~/.nvm/versions/node/v16.9.1/bin/node
- Yarn: 3.0.0 - /usr/local/bin/yarn
- npm: 7.21.1 - ~/.nvm/versions/node/v16.9.1/bin/npm
- Monorepos:
- npmPackages:
- eslint: ^7.30.0 => 7.30.0
- jest: ^27.0.6 => 27.2.5
- webpack: ^5.52.0 => 5.58.1
Possible solution
Either bail out of the Class visitor in @babel/helper-create-class-features-plugin when the class is annotated with declare, or ensure that the typescript transform in an earlier different plugin pass than the class features plugin so that the fields init nodes. I'll be submitting a PR for the first option momentarily.
Additional context
No response
💻
How are you using Babel?
babel-loader (webpack)
Input code
Babel REPL
Configuration file name
babel.config.js
Configuration
Current and expected behavior
Current behaviour: (omitting helpers - happens with
import-helpersor when they are inline.)Expected behaviour:
// no "defineProperty" for the static class propEnvironment
Possible solution
Either bail out of the
Classvisitor in @babel/helper-create-class-features-plugin when the class is annotated withdeclare, or ensure that the typescript transform in an earlier different plugin pass than the class features plugin so that the fields init nodes. I'll be submitting a PR for the first option momentarily.Additional context
No response