improve helper-create-class-features typings#14530
improve helper-create-class-features typings#14530nicolo-ribaudo merged 4 commits intobabel:mainfrom
Conversation
| if (state.classRef?.name && state.classRef.name !== innerBindingRef?.name) { | ||
| // todo: use innerBinding.referencePaths to avoid full traversal | ||
| if ( | ||
| innerBindingRef != null && |
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/51940/ |
6dd28a7 to
3179cb8
Compare
| >; | ||
|
|
||
| function getKey(node: SupportedElement) { | ||
| if (node.type === "StaticBlock") { |
There was a problem hiding this comment.
Maybe we should throw plugin ordering errors for StaticBlock seen here.
There was a problem hiding this comment.
This seems to be broken regardless of the plugin ordering, when using this test:
const code = `
@dec
class A {
static {
x = 2;
}
}
`;
const out = babel.transformSync(code, {
configFile: false,
plugins: [
[
require("@babel/plugin-proposal-decorators"),
{ version: "2018-09", decoratorsBeforeExport: true },
],
require("@babel/plugin-proposal-class-static-block"),
],
});in main it throws; with this PR it discards the static block. Lets keep this PR as internal-only, but that bug should then be fixed.
There was a problem hiding this comment.
| if (node.type === "StaticBlock") { | |
| if (node.type === "StaticBlock") { | |
| // TODO: Fix compatibility between 2018-09 decorators and static blocks |
There was a problem hiding this comment.
Ok actually, let's just add an error as you did for accessor properties. If someone wants to use static blocks they can upgrade their code to use the new decorators proposal.
f7fdbfe to
8fc721d
Compare
8fc721d to
e8f4543
Compare
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
We can merge this with a single ✔️, since the changes are almost only related to type annotations (and the other changes are very minor refactors just to help TS).
Improved
helper-create-class-featurestypings. The type-checker found a bug that we didn't take into account some class members in the 2018-09 decorator transform.