You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
23 KiB
1 line
23 KiB
1 month ago
|
{"version":3,"names":["_t","require","_index","isArrayTypeAnnotation","isBinaryExpression","isCallExpression","isForOfStatement","isIndexedAccessType","isMemberExpression","isObjectPattern","isOptionalMemberExpression","isYieldExpression","isStatement","PRECEDENCE","Map","getBinaryPrecedence","node","nodeType","get","operator","isTSTypeExpression","isClassExtendsClause","parent","parentType","type","superClass","hasPostfixPart","object","callee","tag","NullableTypeAnnotation","FunctionTypeAnnotation","tokenContext","Boolean","TokenContext","arrowFlowReturnType","UpdateExpression","needsParenBeforeExpressionBrace","expressionStatement","arrowBody","ObjectExpression","DoExpression","async","Binary","left","parentPos","nodePos","right","undefined","UnionTypeAnnotation","OptionalIndexedAccessType","objectType","TSAsExpression","TSUnionType","TSInferType","TSInstantiationExpression","typeParameters","BinaryExpression","inForStatementInit","SequenceExpression","property","YieldExpression","test","ClassExpression","exportDefault","UnaryLike","FunctionExpression","ConditionalExpression","OptionalMemberExpression","AssignmentExpression","LogicalExpression","Identifier","_node$extra","extra","parenthesized","rightType","id","name","isFollowedByBracket","computed","optional","forHead","forInHead","forOfHead","await"],"sources":["../../src/node/parentheses.ts"],"sourcesContent":["import {\n isArrayTypeAnnotation,\n isBinaryExpression,\n isCallExpression,\n isForOfStatement,\n isIndexedAccessType,\n isMemberExpression,\n isObjectPattern,\n isOptionalMemberExpression,\n isYieldExpression,\n isStatement,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nimport { TokenContext } from \"./index.ts\";\n\nconst PRECEDENCE = new Map([\n [\"||\", 0],\n [\"??\", 0],\n [\"|>\", 0],\n [\"&&\", 1],\n [\"|\", 2],\n [\"^\", 3],\n [\"&\", 4],\n [\"==\", 5],\n [\"===\", 5],\n [\"!=\", 5],\n [\"!==\", 5],\n [\"<\", 6],\n [\">\", 6],\n [\"<=\", 6],\n [\">=\", 6],\n [\"in\", 6],\n [\"instanceof\", 6],\n [\">>\", 7],\n [\"<<\", 7],\n [\">>>\", 7],\n [\"+\", 8],\n [\"-\", 8],\n [\"*\", 9],\n [\"/\", 9],\n [\"%\", 9],\n [\"**\", 10],\n]);\n\nfunction getBinaryPrecedence(\n node: t.Binary | t.TSAsExpression | t.TSSatisfiesExpression,\n nodeType: string,\n): number;\nfunction getBinaryPrecedence(\n node: t.Node,\n nodeType: string,\n): number | undefined;\nfunction getBinaryPrecedence(node: t.Node, nodeType: string) {\n if (nodeType === \"BinaryExpression\" || nodeType === \"LogicalExpression\") {\n return PRECEDENCE.get((node as t.Binary).operator);\n }\n if (nodeType === \"TSAsExpression\" || nodeType === \"TSSatisfiesExpression\") {\n return PRECEDENCE.get(\"in\");\n }\n}\n\nfunction isTSTypeExpression(nodeType: string) {\n return (\n nodeType === \"TSAsExpression\" ||\n nodeType === \"TSSatisfiesExpression\" ||\n nodeType === \"TSTypeAssertion\"\n );\n}\n\nconst isClassExtendsClause = (\n node: t.Node,\n parent: t.Node,\n): parent is t.Class => {\n const parentType = parent.type;\n return (\n (parentType === \"ClassDeclaration\" || parentType === \"ClassExpression\") &&\n parent.superClass === node\n );\n};\n\nconst hasPostfixPart = (node: t.Node, parent: t.Node) => {\n const parentType = parent.type;\n return (\n ((parentType === \"MemberExpression\" ||\n parentType === \"OptionalMemberExpression\") &&\n parent.object === node) ||\n ((parentType === \"CallExpression\" ||\n parentType === \"OptionalCallExpression\" ||\n parentType === \"NewExpression\") &&\n parent.callee === node) ||\n (parentType === \"TaggedTemplateExpression\" && parent.tag === node) ||\n parentType === \"TSNonNullExpression\"\n );\n};\n\nexport function NullableTypeAnnotation(\n node: t.NullableTypeAnnotation,\n parent: t.Node,\n): boolean {\n return isArrayTypeAnnotation(parent);\n}\n\nexport function FunctionTypeAnnotation(\n node: t.FunctionTypeAnnotation,\n parent: t.Node,\n tokenContext: number,\n): boolean {\n const parentType = parent.t
|