Skip to content

Commit 871539b

Browse files
committed
fix(estree): types
Signed-off-by: Tony Gorez <[email protected]>
1 parent ed1894f commit 871539b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

workspaces/js-x-ray/src/types/estree.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,19 @@ export function isLiteral(
3131
export function isTemplateLiteral(
3232
node: any
3333
): node is ESTree.TemplateLiteral {
34-
return isNode(node) &&
35-
node.type === "TemplateLiteral" &&
36-
node.quasis.at(0).type === "TemplateElement" &&
37-
typeof node.quasis.at(0).value.raw === "string";
34+
if (!isNode(node) || node.type !== "TemplateLiteral") {
35+
return false;
36+
}
37+
38+
const firstQuasi = node.quasis.at(0);
39+
if (!firstQuasi) {
40+
return false;
41+
}
42+
43+
return (
44+
firstQuasi.type === "TemplateElement" &&
45+
typeof firstQuasi.value.raw === "string"
46+
);
3847
}
3948

4049
export function isCallExpression(

0 commit comments

Comments
 (0)