Comparing version 0.5.1 to 0.5.2
@@ -23,3 +23,3 @@ // src/lang.ts | ||
if (isTs(lang)) { | ||
plugins.push(["typescript", { dts: lang === "dts" }]); | ||
plugins.push(lang === "dts" ? ["typescript", { dts: true }] : "typescript"); | ||
if (REGEX_LANG_JSX.test(lang)) | ||
@@ -34,4 +34,4 @@ plugins.push("jsx"); | ||
sourceType: "module", | ||
plugins, | ||
...options | ||
...options, | ||
plugins | ||
}); | ||
@@ -44,2 +44,4 @@ return program; | ||
function isTypeOf(node, types) { | ||
if (!node) | ||
return false; | ||
return types.some((type) => { | ||
@@ -51,3 +53,3 @@ if (type === "Function") { | ||
} else { | ||
return node?.type === type; | ||
return node.type === type; | ||
} | ||
@@ -57,9 +59,9 @@ }); | ||
function isCallOf(node, test) { | ||
return !!(node && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : Array.isArray(test) ? test.includes(node.callee.name) : test(node.callee.name))); | ||
return !!node && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : Array.isArray(test) ? test.includes(node.callee.name) : test(node.callee.name)); | ||
} | ||
function isLiteralType(node) { | ||
return node.type.endsWith("Literal"); | ||
return !!node && node.type.endsWith("Literal"); | ||
} | ||
function isFunctionType(node) { | ||
return /Function(?:Expression|Declaration)$|Method$/.test(node.type); | ||
return !!node && /Function(?:Expression|Declaration)$|Method$/.test(node.type); | ||
} | ||
@@ -66,0 +68,0 @@ var TS_NODE_TYPES = [ |
@@ -30,6 +30,6 @@ import { ParserOptions } from '@babel/parser'; | ||
}>; | ||
declare function isTypeOf<K extends NodeType>(node: Node, types: Readonly<K[]>): node is GetNode<K>; | ||
declare function isTypeOf<K extends NodeType>(node: Node | undefined | null, types: Readonly<K[]>): node is GetNode<K>; | ||
declare function isCallOf(node: Node | null | undefined, test: string | string[] | ((id: string) => boolean)): node is CallExpression; | ||
declare function isLiteralType(node: Node): node is Literal; | ||
declare function isFunctionType(node: Node): node is Function; | ||
declare function isLiteralType(node: Node | undefined | null): node is Literal; | ||
declare function isFunctionType(node: Node | undefined | null): node is Function; | ||
declare const TS_NODE_TYPES: readonly ["TSAsExpression", "TSTypeAssertion", "TSNonNullExpression", "TSInstantiationExpression", "TSSatisfiesExpression"]; | ||
@@ -36,0 +36,0 @@ declare function unwrapTSNode(node: Node): Node; |
@@ -23,3 +23,3 @@ // src/lang.ts | ||
if (isTs(lang)) { | ||
plugins.push(["typescript", { dts: lang === "dts" }]); | ||
plugins.push(lang === "dts" ? ["typescript", { dts: true }] : "typescript"); | ||
if (REGEX_LANG_JSX.test(lang)) | ||
@@ -34,4 +34,4 @@ plugins.push("jsx"); | ||
sourceType: "module", | ||
plugins, | ||
...options | ||
...options, | ||
plugins | ||
}); | ||
@@ -44,2 +44,4 @@ return program; | ||
function isTypeOf(node, types) { | ||
if (!node) | ||
return false; | ||
return types.some((type) => { | ||
@@ -51,3 +53,3 @@ if (type === "Function") { | ||
} else { | ||
return node?.type === type; | ||
return node.type === type; | ||
} | ||
@@ -57,9 +59,9 @@ }); | ||
function isCallOf(node, test) { | ||
return !!(node && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : Array.isArray(test) ? test.includes(node.callee.name) : test(node.callee.name))); | ||
return !!node && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : Array.isArray(test) ? test.includes(node.callee.name) : test(node.callee.name)); | ||
} | ||
function isLiteralType(node) { | ||
return node.type.endsWith("Literal"); | ||
return !!node && node.type.endsWith("Literal"); | ||
} | ||
function isFunctionType(node) { | ||
return /Function(?:Expression|Declaration)$|Method$/.test(node.type); | ||
return !!node && /Function(?:Expression|Declaration)$|Method$/.test(node.type); | ||
} | ||
@@ -66,0 +68,0 @@ var TS_NODE_TYPES = [ |
{ | ||
"name": "ast-kit", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"packageManager": "pnpm@8.6.0", | ||
@@ -28,3 +28,3 @@ "description": "AST Toolkit.", | ||
}, | ||
"./*": "./*" | ||
"./package.json": "./package.json" | ||
}, | ||
@@ -31,0 +31,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38422
1142