Skip to content
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

Restore class fields transform compat with old @babel/types #14231

Merged
merged 1 commit into from Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -82,7 +82,8 @@ function extractElementDescriptor(
prop("decorators", takeDecorators(node as Decorable)),
prop(
"static",
!t.isStaticBlock(node) && node.static && t.booleanLiteral(true),
// @ts-expect-error: TS doesn't infer that node is not a StaticBlock
!t.isStaticBlock?.(node) && node.static && t.booleanLiteral(true),
),
prop("key", getKey(node)),
].filter(Boolean);
Expand Down
Expand Up @@ -911,7 +911,8 @@ function replaceThisContext(
getSuperRef,
getObjectRef() {
state.needsClassRef = true;
return t.isStaticBlock(path.node) || path.node.static
// @ts-expect-error: TS doesn't infer that path.node is not a StaticBlock
return t.isStaticBlock?.(path.node) || path.node.static
? ref
: t.memberExpression(ref, t.identifier("prototype"));
},
Expand Down Expand Up @@ -964,7 +965,8 @@ export function buildFieldsInitNodes(
for (const prop of props) {
prop.isClassProperty() && ts.assertFieldTransformed(prop);

const isStatic = !t.isStaticBlock(prop.node) && prop.node.static;
// @ts-expect-error: TS doesn't infer that prop.node is not a StaticBlock
const isStatic = !t.isStaticBlock?.(prop.node) && prop.node.static;
const isInstance = !isStatic;
const isPrivate = prop.isPrivate();
const isPublic = !isPrivate;
Expand Down
Expand Up @@ -242,7 +242,8 @@ export function createClassFeaturePlugin({
(referenceVisitor, state) => {
if (isDecorated) return;
for (const prop of props) {
if (t.isStaticBlock(prop.node) || prop.node.static) continue;
// @ts-expect-error: TS doesn't infer that prop.node is not a StaticBlock
if (t.isStaticBlock?.(prop.node) || prop.node.static) continue;
prop.traverse(referenceVisitor, state);
}
},
Expand Down