Server IP : 150.95.80.236 / Your IP : 52.15.224.97 Web Server : Apache System : Linux host-150-95-80-236 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : social-telecare ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/pcu.in.th/api-uat.pcu.in.th/node_modules/@babel/traverse/lib/path/inference/ |
Upload File : |
{"version":3,"names":["_t","require","_infererReference","_util","BOOLEAN_BINARY_OPERATORS","BOOLEAN_UNARY_OPERATORS","NUMBER_BINARY_OPERATORS","NUMBER_UNARY_OPERATORS","STRING_UNARY_OPERATORS","anyTypeAnnotation","arrayTypeAnnotation","booleanTypeAnnotation","buildMatchMemberExpression","genericTypeAnnotation","identifier","nullLiteralTypeAnnotation","numberTypeAnnotation","stringTypeAnnotation","tupleTypeAnnotation","unionTypeAnnotation","voidTypeAnnotation","isIdentifier","VariableDeclarator","get","getTypeAnnotation","TypeCastExpression","node","typeAnnotation","validParent","TSAsExpression","TSNonNullExpression","NewExpression","callee","type","TemplateLiteral","UnaryExpression","operator","indexOf","BinaryExpression","right","left","isBaseType","LogicalExpression","argumentTypes","createUnionType","ConditionalExpression","SequenceExpression","pop","ParenthesizedExpression","AssignmentExpression","UpdateExpression","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","RegExpLiteral","ObjectExpression","ArrayExpression","RestElement","Func","isArrayFrom","isObjectKeys","isObjectValues","isObjectEntries","CallExpression","name","resolveCall","TaggedTemplateExpression","resolve","isFunction","async","generator","returnType"],"sources":["../../../src/path/inference/inferers.ts"],"sourcesContent":["import {\n BOOLEAN_BINARY_OPERATORS,\n BOOLEAN_UNARY_OPERATORS,\n NUMBER_BINARY_OPERATORS,\n NUMBER_UNARY_OPERATORS,\n STRING_UNARY_OPERATORS,\n anyTypeAnnotation,\n arrayTypeAnnotation,\n booleanTypeAnnotation,\n buildMatchMemberExpression,\n genericTypeAnnotation,\n identifier,\n nullLiteralTypeAnnotation,\n numberTypeAnnotation,\n stringTypeAnnotation,\n tupleTypeAnnotation,\n unionTypeAnnotation,\n voidTypeAnnotation,\n isIdentifier,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nexport { default as Identifier } from \"./inferer-reference.ts\";\n\nimport { createUnionType } from \"./util.ts\";\nimport type NodePath from \"../index.ts\";\n\nexport function VariableDeclarator(this: NodePath<t.VariableDeclarator>) {\n if (!this.get(\"id\").isIdentifier()) return;\n return this.get(\"init\").getTypeAnnotation();\n}\n\nexport function TypeCastExpression(node: t.TypeCastExpression) {\n return node.typeAnnotation;\n}\n\nTypeCastExpression.validParent = true;\n\nexport function TSAsExpression(node: t.TSAsExpression) {\n return node.typeAnnotation;\n}\n\nTSAsExpression.validParent = true;\n\nexport function TSNonNullExpression(this: NodePath<t.TSNonNullExpression>) {\n return this.get(\"expression\").getTypeAnnotation();\n}\n\nexport function NewExpression(\n this: NodePath<t.NewExpression>,\n node: t.NewExpression,\n) {\n if (node.callee.type === \"Identifier\") {\n // only resolve identifier callee\n return genericTypeAnnotation(node.callee);\n }\n}\n\nexport function TemplateLiteral() {\n return stringTypeAnnotation();\n}\n\nexport function UnaryExpression(node: t.UnaryExpression) {\n const operator = node.operator;\n\n if (operator === \"void\") {\n return voidTypeAnnotation();\n } else if (NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) {\n return numberTypeAnnotation();\n } else if (STRING_UNARY_OPERATORS.indexOf(operator) >= 0) {\n return stringTypeAnnotation();\n } else if (BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) {\n return booleanTypeAnnotation();\n }\n}\n\nexport function BinaryExpression(\n this: NodePath<t.BinaryExpression>,\n node: t.BinaryExpression,\n) {\n const operator = node.operator;\n\n if (NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {\n return numberTypeAnnotation();\n } else if (BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) {\n return booleanTypeAnnotation();\n } else if (operator === \"+\") {\n const right = this.get(\"right\");\n const left = this.get(\"left\");\n\n if (left.isBaseType(\"number\") && right.isBaseType(\"number\")) {\n // both numbers so this will be a number\n return numberTypeAnnotation();\n } else if (left.isBaseType(\"string\") || right.isBaseType(\"string\")) {\n // one is a string so the result will be a string\n return stringTypeAnnotation();\n }\n\n // unsure if left and right are strings or numbers so stay on the safe side\n return unionTypeAnnotation([\n stringTypeAnnotation(),\n numberTypeAnnotation(),\n ]);\n }\n}\n\nexport function LogicalExpression(this: NodePath<t.LogicalExpression>) {\n const argumentTypes = [\n this.get(\"left\").getTypeAnnotation(),\n this.get(\"right\").getTypeAnnotation(),\n ];\n\n return createUnionType(argumentTypes);\n}\n\nexport function ConditionalExpression(this: NodePath<t.ConditionalExpression>) {\n const argumentTypes = [\n this.get(\"consequent\").getTypeAnnotation(),\n this.get(\"alternate\").getTypeAnnotation(),\n ];\n\n return createUnionType(argumentTypes);\n}\n\nexport function SequenceExpression(this: NodePath<t.SequenceExpression>) {\n return this.get(\"expressions\").pop().getTypeAnnotation();\n}\n\nexport function ParenthesizedExpression(\n this: NodePath<t.ParenthesizedExpression>,\n) {\n return this.get(\"expression\").getTypeAnnotation();\n}\n\nexport function AssignmentExpression(this: NodePath<t.AssignmentExpression>) {\n return this.get(\"right\").getTypeAnnotation();\n}\n\nexport function UpdateExpression(\n this: NodePath<t.UpdateExpression>,\n node: t.UpdateExpression,\n) {\n const operator = node.operator;\n if (operator === \"++\" || operator === \"--\") {\n return numberTypeAnnotation();\n }\n}\n\nexport function StringLiteral() {\n return stringTypeAnnotation();\n}\n\nexport function NumericLiteral() {\n return numberTypeAnnotation();\n}\n\nexport function BooleanLiteral() {\n return booleanTypeAnnotation();\n}\n\nexport function NullLiteral() {\n return nullLiteralTypeAnnotation();\n}\n\nexport function RegExpLiteral() {\n return genericTypeAnnotation(identifier(\"RegExp\"));\n}\n\nexport function ObjectExpression() {\n return genericTypeAnnotation(identifier(\"Object\"));\n}\n\nexport function ArrayExpression() {\n return genericTypeAnnotation(identifier(\"Array\"));\n}\n\nexport function RestElement() {\n return ArrayExpression();\n}\n\nRestElement.validParent = true;\n\nfunction Func() {\n return genericTypeAnnotation(identifier(\"Function\"));\n}\n\nexport {\n Func as FunctionExpression,\n Func as ArrowFunctionExpression,\n Func as FunctionDeclaration,\n Func as ClassExpression,\n Func as ClassDeclaration,\n};\n\nconst isArrayFrom = buildMatchMemberExpression(\"Array.from\");\nconst isObjectKeys = buildMatchMemberExpression(\"Object.keys\");\nconst isObjectValues = buildMatchMemberExpression(\"Object.values\");\nconst isObjectEntries = buildMatchMemberExpression(\"Object.entries\");\nexport function CallExpression(this: NodePath<t.CallExpression>) {\n const { callee } = this.node;\n if (isObjectKeys(callee)) {\n return arrayTypeAnnotation(stringTypeAnnotation());\n } else if (\n isArrayFrom(callee) ||\n isObjectValues(callee) ||\n // Detect \"var foo = Array()\" calls so we can optimize for arrays vs iterables.\n isIdentifier(callee, { name: \"Array\" })\n ) {\n return arrayTypeAnnotation(anyTypeAnnotation());\n } else if (isObjectEntries(callee)) {\n return arrayTypeAnnotation(\n tupleTypeAnnotation([stringTypeAnnotation(), anyTypeAnnotation()]),\n );\n }\n\n return resolveCall(this.get(\"callee\"));\n}\n\nexport function TaggedTemplateExpression(\n this: NodePath<t.TaggedTemplateExpression>,\n) {\n return resolveCall(this.get(\"tag\"));\n}\n\nfunction resolveCall(callee: NodePath) {\n callee = callee.resolve();\n\n if (callee.isFunction()) {\n const { node } = callee;\n if (node.async) {\n if (node.generator) {\n return genericTypeAnnotation(identifier(\"AsyncIterator\"));\n } else {\n return genericTypeAnnotation(identifier(\"Promise\"));\n }\n } else {\n if (node.generator) {\n return genericTypeAnnotation(identifier(\"Iterator\"));\n } else if (callee.node.returnType) {\n return callee.node.returnType;\n } else {\n // todo: get union type of all return arguments\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,I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