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
improve helper-create-class-features typings #14530
improve helper-create-class-features typings #14530
Conversation
if (state.classRef?.name && state.classRef.name !== innerBindingRef?.name) { | ||
// todo: use innerBinding.referencePaths to avoid full traversal | ||
if ( | ||
innerBindingRef != null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #14519 (comment).
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should throw plugin ordering errors for StaticBlock
seen here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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-features
typings. The type-checker found a bug that we didn't take into account some class members in the 2018-09 decorator transform.