Support class-static-block proposal (#9476)
* Support class-static-block proposal * Update changelog
This commit is contained in:
1 parent
d9f5630ff5
commit
13f3336bba
9 files changed
+172
-4
No files matched your search
@@ -39,6 +39,7 @@ function babelOptions({ sourceType, extraPlugins = [] }) {
|
||||
["recordAndTuple", { syntaxType: "hash" }],
|
||||
"decimal",
|
||||
"moduleStringNames",
|
||||
"classStaticBlock",
|
||||
...extraPlugins,
|
||||
],
|
||||
tokens: true,
|
||||
|
||||
@@ -894,11 +894,16 @@ function printPathNoParens(path, options, print, args) {
|
||||
case "Import":
|
||||
return "import";
|
||||
case "TSModuleBlock":
|
||||
case "BlockStatement": {
|
||||
case "BlockStatement":
|
||||
case "StaticBlock": {
|
||||
const naked = path.call((bodyPath) => {
|
||||
return printStatementSequence(bodyPath, options, print);
|
||||
}, "body");
|
||||
|
||||
if (n.type === "StaticBlock") {
|
||||
parts.push("static ");
|
||||
}
|
||||
|
||||
const hasContent = n.body.some((node) => node.type !== "EmptyStatement");
|
||||
const hasDirectives = n.directives && n.directives.length > 0;
|
||||
|
||||
@@ -920,9 +925,10 @@ function printPathNoParens(path, options, print, args) {
|
||||
parent.type === "DoExpression" ||
|
||||
(parent.type === "CatchClause" && !parentParent.finalizer) ||
|
||||
parent.type === "TSModuleDeclaration" ||
|
||||
parent.type === "TSDeclareFunction")
|
||||
parent.type === "TSDeclareFunction" ||
|
||||
n.type === "StaticBlock")
|
||||
) {
|
||||
return "{}";
|
||||
return concat([...parts, "{}"]);
|
||||
}
|
||||
|
||||
parts.push("{");
|
||||
|
||||
Reference in new issue
Block a user