Skip to content

Commit 220d981

Browse files
committed
feat: Add more type guards.
1 parent 3545994 commit 220d981

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

source/is.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ export function isCallExpression(node: es.Node): node is es.CallExpression {
3939
return node.type === "CallExpression";
4040
}
4141

42+
export function isExportNamedDeclaration(
43+
node: es.Node
44+
): node is es.ExportNamedDeclaration {
45+
return node.type === "ExportNamedDeclaration";
46+
}
47+
4248
export function isExpressionStatement(
4349
node: es.Node
4450
): node is es.ExpressionStatement {
@@ -69,6 +75,10 @@ export function isMemberExpression(node: es.Node): node is es.MemberExpression {
6975
return node.type === "MemberExpression";
7076
}
7177

78+
export function isNewExpression(node: es.Node): node is es.NewExpression {
79+
return node.type === "NewExpression";
80+
}
81+
7282
export function isObjectExpression(node: es.Node): node is es.ObjectExpression {
7383
return node.type === "ObjectExpression";
7484
}
@@ -81,6 +91,10 @@ export function isProgram(node: es.Node): node is es.Program {
8191
return node.type === "Program";
8292
}
8393

94+
export function isProperty(node: es.Node): node is es.Property {
95+
return node.type === "Property";
96+
}
97+
8498
export function isRestElement(node: es.Node): node is es.RestElement {
8599
return node.type === "RestElement";
86100
}
@@ -89,6 +103,14 @@ export function isThisExpression(node: es.Node): node is es.ThisExpression {
89103
return node.type === "ThisExpression";
90104
}
91105

106+
export function isTSTypeLiteral(node: es.Node): node is es.TSTypeLiteral {
107+
return node.type === "TSTypeLiteral";
108+
}
109+
110+
export function isTSTypeReference(node: es.Node): node is es.TSTypeReference {
111+
return node.type === "TSTypeReference";
112+
}
113+
92114
export function isVariableDeclarator(
93115
node: es.Node
94116
): node is es.VariableDeclarator {

0 commit comments

Comments
 (0)