ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
1,508 lines • 96.4 kB
JavaScript
"use strict";
// -----------------------
// WARNING - DO NOT modify the "is" methods of the TypeGuards class directly. It is code generated by createTypeGuardsUtility.ts
//
// Note: This file is excluded from code coverage reports because it's automatically maintained (low risk).
// -----------------------
Object.defineProperty(exports, "__esModule", { value: true });
var typescript_1 = require("./../typescript");
/**
* Type guards for checking the type of a node.
*/
var TypeGuards = /** @class */ (function () {
function TypeGuards() {
}
/**
* Gets if the node has an expression.
* @param node - Node to check.
*/
TypeGuards.hasExpression = function (node) {
// this method is manually maintained
if (node.getExpression == null)
return false;
return node.getExpression() != null;
};
/**
* Gets if the node has a name.
* @param node - Node to check.
*/
TypeGuards.hasName = function (node) {
// this method is manually maintained
if (node.getName == null)
return false;
return typeof node.getName() === "string";
};
/**
* Gets if the node is an AbstractableNode.
* @param node - Node to check.
*/
TypeGuards.isAbstractableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
case typescript_1.SyntaxKind.GetAccessor:
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.PropertyDeclaration:
case typescript_1.SyntaxKind.SetAccessor:
return true;
default:
return false;
}
};
/**
* Gets if the node is an AmbientableNode.
* @param node - Node to check.
*/
TypeGuards.isAmbientableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
case typescript_1.SyntaxKind.EnumDeclaration:
case typescript_1.SyntaxKind.FunctionDeclaration:
case typescript_1.SyntaxKind.InterfaceDeclaration:
case typescript_1.SyntaxKind.ModuleDeclaration:
case typescript_1.SyntaxKind.VariableStatement:
case typescript_1.SyntaxKind.TypeAliasDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ArgumentedNode.
* @param node - Node to check.
*/
TypeGuards.isArgumentedNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CallExpression:
case typescript_1.SyntaxKind.NewExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ArrayLiteralExpression.
* @param node - Node to check.
*/
TypeGuards.isArrayLiteralExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ArrayLiteralExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ArrayTypeNode.
* @param node - Node to check.
*/
TypeGuards.isArrayTypeNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ArrayType:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ArrowFunction.
* @param node - Node to check.
*/
TypeGuards.isArrowFunction = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ArrowFunction:
return true;
default:
return false;
}
};
/**
* Gets if the node is an AsExpression.
* @param node - Node to check.
*/
TypeGuards.isAsExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.AsExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is an AsyncableNode.
* @param node - Node to check.
*/
TypeGuards.isAsyncableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.ArrowFunction:
case typescript_1.SyntaxKind.FunctionDeclaration:
case typescript_1.SyntaxKind.FunctionExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is an AwaitExpression.
* @param node - Node to check.
*/
TypeGuards.isAwaitExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.AwaitExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is an AwaitableNode.
* @param node - Node to check.
*/
TypeGuards.isAwaitableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ForOfStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a BinaryExpression.
* @param node - Node to check.
*/
TypeGuards.isBinaryExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.BinaryExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a BindingNamedNode.
* @param node - Node to check.
*/
TypeGuards.isBindingNamedNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.VariableDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a Block.
* @param node - Node to check.
*/
TypeGuards.isBlock = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Block:
return true;
default:
return false;
}
};
/**
* Gets if the node is a BodiedNode.
* @param node - Node to check.
*/
TypeGuards.isBodiedNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.GetAccessor:
case typescript_1.SyntaxKind.SetAccessor:
case typescript_1.SyntaxKind.ArrowFunction:
case typescript_1.SyntaxKind.FunctionExpression:
case typescript_1.SyntaxKind.ModuleDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a BodyableNode.
* @param node - Node to check.
*/
TypeGuards.isBodyableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Constructor:
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.FunctionDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a BooleanLiteral.
* @param node - Node to check.
*/
TypeGuards.isBooleanLiteral = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.FalseKeyword:
case typescript_1.SyntaxKind.TrueKeyword:
return true;
default:
return false;
}
};
/**
* Gets if the node is a BreakStatement.
* @param node - Node to check.
*/
TypeGuards.isBreakStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.BreakStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a CallExpression.
* @param node - Node to check.
*/
TypeGuards.isCallExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CallExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a CallSignatureDeclaration.
* @param node - Node to check.
*/
TypeGuards.isCallSignatureDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CallSignature:
return true;
default:
return false;
}
};
/**
* Gets if the node is a CaseBlock.
* @param node - Node to check.
*/
TypeGuards.isCaseBlock = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CaseBlock:
return true;
default:
return false;
}
};
/**
* Gets if the node is a CaseClause.
* @param node - Node to check.
*/
TypeGuards.isCaseClause = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CaseClause:
return true;
default:
return false;
}
};
/**
* Gets if the node is a CatchClause.
* @param node - Node to check.
*/
TypeGuards.isCatchClause = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CatchClause:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ChildOrderableNode.
* @param node - Node to check.
*/
TypeGuards.isChildOrderableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
case typescript_1.SyntaxKind.Constructor:
case typescript_1.SyntaxKind.GetAccessor:
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.PropertyDeclaration:
case typescript_1.SyntaxKind.SetAccessor:
case typescript_1.SyntaxKind.EnumDeclaration:
case typescript_1.SyntaxKind.FunctionDeclaration:
case typescript_1.SyntaxKind.CallSignature:
case typescript_1.SyntaxKind.ConstructSignature:
case typescript_1.SyntaxKind.IndexSignature:
case typescript_1.SyntaxKind.InterfaceDeclaration:
case typescript_1.SyntaxKind.MethodSignature:
case typescript_1.SyntaxKind.PropertySignature:
case typescript_1.SyntaxKind.ModuleDeclaration:
case typescript_1.SyntaxKind.BreakStatement:
case typescript_1.SyntaxKind.CaseClause:
case typescript_1.SyntaxKind.ContinueStatement:
case typescript_1.SyntaxKind.DefaultClause:
case typescript_1.SyntaxKind.DoStatement:
case typescript_1.SyntaxKind.ExpressionStatement:
case typescript_1.SyntaxKind.ForInStatement:
case typescript_1.SyntaxKind.ForOfStatement:
case typescript_1.SyntaxKind.ForStatement:
case typescript_1.SyntaxKind.IfStatement:
case typescript_1.SyntaxKind.LabeledStatement:
case typescript_1.SyntaxKind.ReturnStatement:
case typescript_1.SyntaxKind.SwitchStatement:
case typescript_1.SyntaxKind.VariableStatement:
case typescript_1.SyntaxKind.WhileStatement:
case typescript_1.SyntaxKind.WithStatement:
case typescript_1.SyntaxKind.TypeAliasDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ClassDeclaration.
* @param node - Node to check.
*/
TypeGuards.isClassDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a CommaListExpression.
* @param node - Node to check.
*/
TypeGuards.isCommaListExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CommaListExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ComputedPropertyName.
* @param node - Node to check.
*/
TypeGuards.isComputedPropertyName = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ComputedPropertyName:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ConditionalExpression.
* @param node - Node to check.
*/
TypeGuards.isConditionalExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ConditionalExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ConstructSignatureDeclaration.
* @param node - Node to check.
*/
TypeGuards.isConstructSignatureDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ConstructSignature:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ConstructorDeclaration.
* @param node - Node to check.
*/
TypeGuards.isConstructorDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Constructor:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ConstructorTypeNode.
* @param node - Node to check.
*/
TypeGuards.isConstructorTypeNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ConstructorType:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ContinueStatement.
* @param node - Node to check.
*/
TypeGuards.isContinueStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ContinueStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a DebuggerStatement.
* @param node - Node to check.
*/
TypeGuards.isDebuggerStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.DebuggerStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a DeclarationNamedNode.
* @param node - Node to check.
*/
TypeGuards.isDeclarationNamedNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Parameter:
return true;
default:
return false;
}
};
/**
* Gets if the node is a DecoratableNode.
* @param node - Node to check.
*/
TypeGuards.isDecoratableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
case typescript_1.SyntaxKind.GetAccessor:
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.PropertyDeclaration:
case typescript_1.SyntaxKind.SetAccessor:
case typescript_1.SyntaxKind.Parameter:
return true;
default:
return false;
}
};
/**
* Gets if the node is a Decorator.
* @param node - Node to check.
*/
TypeGuards.isDecorator = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Decorator:
return true;
default:
return false;
}
};
/**
* Gets if the node is a DefaultClause.
* @param node - Node to check.
*/
TypeGuards.isDefaultClause = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.DefaultClause:
return true;
default:
return false;
}
};
/**
* Gets if the node is a DeleteExpression.
* @param node - Node to check.
*/
TypeGuards.isDeleteExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.DeleteExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a DoStatement.
* @param node - Node to check.
*/
TypeGuards.isDoStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.DoStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ElementAccessExpression.
* @param node - Node to check.
*/
TypeGuards.isElementAccessExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ElementAccessExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is an EmptyStatement.
* @param node - Node to check.
*/
TypeGuards.isEmptyStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.EmptyStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is an EnumDeclaration.
* @param node - Node to check.
*/
TypeGuards.isEnumDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.EnumDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is an EnumMember.
* @param node - Node to check.
*/
TypeGuards.isEnumMember = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.EnumMember:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExportAssignment.
* @param node - Node to check.
*/
TypeGuards.isExportAssignment = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ExportAssignment:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExportDeclaration.
* @param node - Node to check.
*/
TypeGuards.isExportDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ExportDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExportSpecifier.
* @param node - Node to check.
*/
TypeGuards.isExportSpecifier = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ExportSpecifier:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExportableNode.
* @param node - Node to check.
*/
TypeGuards.isExportableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
case typescript_1.SyntaxKind.EnumDeclaration:
case typescript_1.SyntaxKind.FunctionDeclaration:
case typescript_1.SyntaxKind.InterfaceDeclaration:
case typescript_1.SyntaxKind.ModuleDeclaration:
case typescript_1.SyntaxKind.VariableStatement:
case typescript_1.SyntaxKind.TypeAliasDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is an Expression.
* @param node - Node to check.
*/
TypeGuards.isExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.AnyKeyword:
case typescript_1.SyntaxKind.BooleanKeyword:
case typescript_1.SyntaxKind.NeverKeyword:
case typescript_1.SyntaxKind.NumberKeyword:
case typescript_1.SyntaxKind.ObjectKeyword:
case typescript_1.SyntaxKind.StringKeyword:
case typescript_1.SyntaxKind.SymbolKeyword:
case typescript_1.SyntaxKind.UndefinedKeyword:
case typescript_1.SyntaxKind.Identifier:
case typescript_1.SyntaxKind.AsExpression:
case typescript_1.SyntaxKind.AwaitExpression:
case typescript_1.SyntaxKind.BinaryExpression:
case typescript_1.SyntaxKind.CallExpression:
case typescript_1.SyntaxKind.CommaListExpression:
case typescript_1.SyntaxKind.ConditionalExpression:
case typescript_1.SyntaxKind.DeleteExpression:
case typescript_1.SyntaxKind.ElementAccessExpression:
case typescript_1.SyntaxKind.ImportKeyword:
case typescript_1.SyntaxKind.MetaProperty:
case typescript_1.SyntaxKind.NewExpression:
case typescript_1.SyntaxKind.NonNullExpression:
case typescript_1.SyntaxKind.OmittedExpression:
case typescript_1.SyntaxKind.ParenthesizedExpression:
case typescript_1.SyntaxKind.PartiallyEmittedExpression:
case typescript_1.SyntaxKind.PostfixUnaryExpression:
case typescript_1.SyntaxKind.PrefixUnaryExpression:
case typescript_1.SyntaxKind.PropertyAccessExpression:
case typescript_1.SyntaxKind.SpreadElement:
case typescript_1.SyntaxKind.SuperKeyword:
case typescript_1.SyntaxKind.ThisKeyword:
case typescript_1.SyntaxKind.TypeAssertionExpression:
case typescript_1.SyntaxKind.TypeOfExpression:
case typescript_1.SyntaxKind.VoidKeyword:
case typescript_1.SyntaxKind.YieldExpression:
case typescript_1.SyntaxKind.ArrowFunction:
case typescript_1.SyntaxKind.FunctionExpression:
case typescript_1.SyntaxKind.JsxClosingFragment:
case typescript_1.SyntaxKind.JsxElement:
case typescript_1.SyntaxKind.JsxExpression:
case typescript_1.SyntaxKind.JsxFragment:
case typescript_1.SyntaxKind.JsxOpeningElement:
case typescript_1.SyntaxKind.JsxOpeningFragment:
case typescript_1.SyntaxKind.JsxSelfClosingElement:
case typescript_1.SyntaxKind.FalseKeyword:
case typescript_1.SyntaxKind.TrueKeyword:
case typescript_1.SyntaxKind.NullKeyword:
case typescript_1.SyntaxKind.FirstLiteralToken:
case typescript_1.SyntaxKind.NumericLiteral:
case typescript_1.SyntaxKind.RegularExpressionLiteral:
case typescript_1.SyntaxKind.StringLiteral:
case typescript_1.SyntaxKind.ArrayLiteralExpression:
case typescript_1.SyntaxKind.ObjectLiteralExpression:
case typescript_1.SyntaxKind.NoSubstitutionTemplateLiteral:
case typescript_1.SyntaxKind.TaggedTemplateExpression:
case typescript_1.SyntaxKind.TemplateExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExpressionStatement.
* @param node - Node to check.
*/
TypeGuards.isExpressionStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ExpressionStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExpressionWithTypeArguments.
* @param node - Node to check.
*/
TypeGuards.isExpressionWithTypeArguments = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ExpressionWithTypeArguments:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExpressionedNode.
* @param node - Node to check.
*/
TypeGuards.isExpressionedNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.AsExpression:
case typescript_1.SyntaxKind.NonNullExpression:
case typescript_1.SyntaxKind.ParenthesizedExpression:
case typescript_1.SyntaxKind.PartiallyEmittedExpression:
case typescript_1.SyntaxKind.SpreadElement:
case typescript_1.SyntaxKind.SpreadAssignment:
case typescript_1.SyntaxKind.TemplateSpan:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExtendsClauseableNode.
* @param node - Node to check.
*/
TypeGuards.isExtendsClauseableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.InterfaceDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is an ExternalModuleReference.
* @param node - Node to check.
*/
TypeGuards.isExternalModuleReference = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ExternalModuleReference:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ForInStatement.
* @param node - Node to check.
*/
TypeGuards.isForInStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ForInStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ForOfStatement.
* @param node - Node to check.
*/
TypeGuards.isForOfStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ForOfStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ForStatement.
* @param node - Node to check.
*/
TypeGuards.isForStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ForStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a FunctionDeclaration.
* @param node - Node to check.
*/
TypeGuards.isFunctionDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.FunctionDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a FunctionExpression.
* @param node - Node to check.
*/
TypeGuards.isFunctionExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.FunctionExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a FunctionLikeDeclaration.
* @param node - Node to check.
*/
TypeGuards.isFunctionLikeDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Constructor:
case typescript_1.SyntaxKind.GetAccessor:
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.SetAccessor:
case typescript_1.SyntaxKind.FunctionDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a FunctionTypeNode.
* @param node - Node to check.
*/
TypeGuards.isFunctionTypeNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.FunctionType:
return true;
default:
return false;
}
};
/**
* Gets if the node is a GeneratorableNode.
* @param node - Node to check.
*/
TypeGuards.isGeneratorableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.YieldExpression:
case typescript_1.SyntaxKind.FunctionDeclaration:
case typescript_1.SyntaxKind.FunctionExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a GetAccessorDeclaration.
* @param node - Node to check.
*/
TypeGuards.isGetAccessorDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.GetAccessor:
return true;
default:
return false;
}
};
/**
* Gets if the node is a HeritageClause.
* @param node - Node to check.
*/
TypeGuards.isHeritageClause = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.HeritageClause:
return true;
default:
return false;
}
};
/**
* Gets if the node is a HeritageClauseableNode.
* @param node - Node to check.
*/
TypeGuards.isHeritageClauseableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
case typescript_1.SyntaxKind.InterfaceDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a Identifier.
* @param node - Node to check.
*/
TypeGuards.isIdentifier = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Identifier:
return true;
default:
return false;
}
};
/**
* Gets if the node is a IfStatement.
* @param node - Node to check.
*/
TypeGuards.isIfStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.IfStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ImplementsClauseableNode.
* @param node - Node to check.
*/
TypeGuards.isImplementsClauseableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ImportDeclaration.
* @param node - Node to check.
*/
TypeGuards.isImportDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ImportDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ImportEqualsDeclaration.
* @param node - Node to check.
*/
TypeGuards.isImportEqualsDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ImportEqualsDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ImportExpression.
* @param node - Node to check.
*/
TypeGuards.isImportExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ImportKeyword:
return true;
default:
return false;
}
};
/**
* Gets if the node is a ImportSpecifier.
* @param node - Node to check.
*/
TypeGuards.isImportSpecifier = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ImportSpecifier:
return true;
default:
return false;
}
};
/**
* Gets if the node is a IndexSignatureDeclaration.
* @param node - Node to check.
*/
TypeGuards.isIndexSignatureDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.IndexSignature:
return true;
default:
return false;
}
};
/**
* Gets if the node is a InitializerExpressionableNode.
* @param node - Node to check.
*/
TypeGuards.isInitializerExpressionableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.PropertyDeclaration:
case typescript_1.SyntaxKind.EnumMember:
case typescript_1.SyntaxKind.Parameter:
case typescript_1.SyntaxKind.PropertySignature:
case typescript_1.SyntaxKind.VariableDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a InitializerGetExpressionableNode.
* @param node - Node to check.
*/
TypeGuards.isInitializerGetExpressionableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.PropertyDeclaration:
case typescript_1.SyntaxKind.EnumMember:
case typescript_1.SyntaxKind.Parameter:
case typescript_1.SyntaxKind.PropertySignature:
case typescript_1.SyntaxKind.VariableDeclaration:
case typescript_1.SyntaxKind.PropertyAssignment:
case typescript_1.SyntaxKind.ShorthandPropertyAssignment:
return true;
default:
return false;
}
};
/**
* Gets if the node is a InitializerSetExpressionableNode.
* @param node - Node to check.
*/
TypeGuards.isInitializerSetExpressionableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.PropertyDeclaration:
case typescript_1.SyntaxKind.EnumMember:
case typescript_1.SyntaxKind.Parameter:
case typescript_1.SyntaxKind.PropertySignature:
case typescript_1.SyntaxKind.VariableDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a InterfaceDeclaration.
* @param node - Node to check.
*/
TypeGuards.isInterfaceDeclaration = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.InterfaceDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a IntersectionTypeNode.
* @param node - Node to check.
*/
TypeGuards.isIntersectionTypeNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.IntersectionType:
return true;
default:
return false;
}
};
/**
* Gets if the node is a IterationStatement.
* @param node - Node to check.
*/
TypeGuards.isIterationStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.DoStatement:
case typescript_1.SyntaxKind.ForInStatement:
case typescript_1.SyntaxKind.ForOfStatement:
case typescript_1.SyntaxKind.ForStatement:
case typescript_1.SyntaxKind.WhileStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDoc.
* @param node - Node to check.
*/
TypeGuards.isJSDoc = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocComment:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocAugmentsTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocAugmentsTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocAugmentsTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocClassTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocClassTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocClassTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocParameterTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocParameterTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocParameterTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocPropertyLikeTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocPropertyLikeTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocParameterTag:
case typescript_1.SyntaxKind.JSDocPropertyTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocPropertyTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocPropertyTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocPropertyTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocReturnTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocReturnTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocReturnTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocAugmentsTag:
case typescript_1.SyntaxKind.JSDocClassTag:
case typescript_1.SyntaxKind.JSDocParameterTag:
case typescript_1.SyntaxKind.JSDocPropertyTag:
case typescript_1.SyntaxKind.JSDocReturnTag:
case typescript_1.SyntaxKind.JSDocTypedefTag:
case typescript_1.SyntaxKind.JSDocTypeTag:
case typescript_1.SyntaxKind.JSDocTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocTypeTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocTypeTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocTypeTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocTypedefTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocTypedefTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocTypedefTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocUnknownTag.
* @param node - Node to check.
*/
TypeGuards.isJSDocUnknownTag = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JSDocTag:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JSDocableNode.
* @param node - Node to check.
*/
TypeGuards.isJSDocableNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.ClassDeclaration:
case typescript_1.SyntaxKind.Constructor:
case typescript_1.SyntaxKind.GetAccessor:
case typescript_1.SyntaxKind.MethodDeclaration:
case typescript_1.SyntaxKind.PropertyDeclaration:
case typescript_1.SyntaxKind.SetAccessor:
case typescript_1.SyntaxKind.EnumDeclaration:
case typescript_1.SyntaxKind.EnumMember:
case typescript_1.SyntaxKind.ImportEqualsDeclaration:
case typescript_1.SyntaxKind.ArrowFunction:
case typescript_1.SyntaxKind.FunctionDeclaration:
case typescript_1.SyntaxKind.FunctionExpression:
case typescript_1.SyntaxKind.CallSignature:
case typescript_1.SyntaxKind.ConstructSignature:
case typescript_1.SyntaxKind.IndexSignature:
case typescript_1.SyntaxKind.InterfaceDeclaration:
case typescript_1.SyntaxKind.MethodSignature:
case typescript_1.SyntaxKind.PropertySignature:
case typescript_1.SyntaxKind.ModuleDeclaration:
case typescript_1.SyntaxKind.ExpressionStatement:
case typescript_1.SyntaxKind.LabeledStatement:
case typescript_1.SyntaxKind.VariableStatement:
case typescript_1.SyntaxKind.TypeAliasDeclaration:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxAttribute.
* @param node - Node to check.
*/
TypeGuards.isJsxAttribute = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxAttribute:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxClosingElement.
* @param node - Node to check.
*/
TypeGuards.isJsxClosingElement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxClosingElement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxClosingFragment.
* @param node - Node to check.
*/
TypeGuards.isJsxClosingFragment = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxClosingFragment:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxElement.
* @param node - Node to check.
*/
TypeGuards.isJsxElement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxElement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxExpression.
* @param node - Node to check.
*/
TypeGuards.isJsxExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxFragment.
* @param node - Node to check.
*/
TypeGuards.isJsxFragment = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxFragment:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxOpeningElement.
* @param node - Node to check.
*/
TypeGuards.isJsxOpeningElement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxOpeningElement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxOpeningFragment.
* @param node - Node to check.
*/
TypeGuards.isJsxOpeningFragment = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxOpeningFragment:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxSelfClosingElement.
* @param node - Node to check.
*/
TypeGuards.isJsxSelfClosingElement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxSelfClosingElement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxSpreadAttribute.
* @param node - Node to check.
*/
TypeGuards.isJsxSpreadAttribute = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxSpreadAttribute:
return true;
default:
return false;
}
};
/**
* Gets if the node is a JsxText.
* @param node - Node to check.
*/
TypeGuards.isJsxText = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.JsxText:
return true;
default:
return false;
}
};
/**
* Gets if the node is a LabeledStatement.
* @param node - Node to check.
*/
TypeGuards.isLabeledStatement = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.LabeledStatement:
return true;
default:
return false;
}
};
/**
* Gets if the node is a LeftHandSideExpression.
* @param node - Node to check.
*/
TypeGuards.isLeftHandSideExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.Identifier:
case typescript_1.SyntaxKind.CallExpression:
case typescript_1.SyntaxKind.ElementAccessExpression:
case typescript_1.SyntaxKind.ImportKeyword:
case typescript_1.SyntaxKind.MetaProperty:
case typescript_1.SyntaxKind.NewExpression:
case typescript_1.SyntaxKind.NonNullExpression:
case typescript_1.SyntaxKind.PropertyAccessExpression:
case typescript_1.SyntaxKind.SuperKeyword:
case typescript_1.SyntaxKind.ThisKeyword:
case typescript_1.SyntaxKind.FunctionExpression:
case typescript_1.SyntaxKind.JsxElement:
case typescript_1.SyntaxKind.JsxFragment:
case typescript_1.SyntaxKind.JsxSelfClosingElement:
case typescript_1.SyntaxKind.FalseKeyword:
case typescript_1.SyntaxKind.TrueKeyword:
case typescript_1.SyntaxKind.NullKeyword:
case typescript_1.SyntaxKind.FirstLiteralToken:
case typescript_1.SyntaxKind.NumericLiteral:
case typescript_1.SyntaxKind.RegularExpressionLiteral:
case typescript_1.SyntaxKind.StringLiteral:
case typescript_1.SyntaxKind.ArrayLiteralExpression:
case typescript_1.SyntaxKind.ObjectLiteralExpression:
case typescript_1.SyntaxKind.NoSubstitutionTemplateLiteral:
case typescript_1.SyntaxKind.TaggedTemplateExpression:
case typescript_1.SyntaxKind.TemplateExpression:
return true;
default:
return false;
}
};
/**
* Gets if the node is a LeftHandSideExpressionedNode.
* @param node - Node to check.
*/
TypeGuards.isLeftHandSideExpressionedNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.CallExpression:
case typescript_1.SyntaxKind.ElementAccessExpression:
case typescript_1.SyntaxKind.NewExpression:
case typescript_1.SyntaxKind.PropertyAccessExpression:
case typescript_1.SyntaxKind.ExpressionWithTypeArguments:
return true;
default:
return false;
}
};
/**
* Gets if the node is a LiteralExpression.
* @param node - Node to check.
*/
TypeGuards.isLiteralExpression = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.FirstLiteralToken:
case typescript_1.SyntaxKind.NumericLiteral:
case typescript_1.SyntaxKind.RegularExpressionLiteral:
case typescript_1.SyntaxKind.StringLiteral:
case typescript_1.SyntaxKind.NoSubstitutionTemplateLiteral:
return true;
default:
return false;
}
};
/**
* Gets if the node is a LiteralLikeNode.
* @param node - Node to check.
*/
TypeGuards.isLiteralLikeNode = function (node) {
switch (node.getKind()) {
case typescript_1.SyntaxKind.FirstLiteralToken:
case typescript_1.SyntaxKind.NumericLiteral:
case typescript_1.SyntaxKind.RegularExpressionLiteral:
case typescript_1.SyntaxKind.StringLiteral:
case typescript_1.SyntaxKind.NoSubstitutionTemplateLiteral:
case typescript_1.SyntaxKind.TemplateHead:
case typescript_1.SyntaxKind.TemplateMiddle:
case typescript_1.S