import * as ts from 'typescript' ; export function isAccessorDeclaration ( node ) { return node . kind === ts . SyntaxKind . GetAccessor || node . kind === ts . SyntaxKind . SetAccessor ; } export function isArrayBindingPattern ( node ) { return node . kind === ts . SyntaxKind . ArrayBindingPattern ; } export function isArrayLiteralExpression ( node ) { return node . kind === ts . SyntaxKind . ArrayLiteralExpression ; } export function isArrayTypeNode ( node ) { return node . kind === ts . SyntaxKind . ArrayType ; } export function isArrowFunction ( node ) { return node . kind === ts . SyntaxKind . ArrowFunction ; } export function isAsExpression ( node ) { return node . kind === ts . SyntaxKind . AsExpression ; } export function isAssertionExpression ( node ) { return node . kind === ts . SyntaxKind . AsExpression || node . kind === ts . SyntaxKind . TypeAssertionExpression ; } export function isAwaitExpression ( node ) { return node . kind === ts . SyntaxKind . AwaitExpression ; } export function isBinaryExpression ( node ) { return node . kind === ts . SyntaxKind . BinaryExpression ; } export function isBindingElement ( node ) { return node . kind === ts . SyntaxKind . BindingElement ; } export function isBindingPattern ( node ) { return node . kind === ts . SyntaxKind . ArrayBindingPattern || node . kind === ts . SyntaxKind . ObjectBindingPattern ; } export function isBlock ( node ) { return node . kind === ts . SyntaxKind . Block ; } export function isBlockLike ( node ) { return ( < any > node ) . statements !== undefined ; } export function isBooleanLiteral ( node ) { return node . kind === ts . SyntaxKind . TrueKeyword || node . kind === ts . SyntaxKind . FalseKeyword ; } export function isBreakOrContinueStatement ( node ) { return node . kind === ts . SyntaxKind . BreakStatement || node . kind === ts . SyntaxKind . ContinueStatement ; } export function isBreakStatement ( node ) { return node . kind === ts . SyntaxKind . BreakStatement ; } export function isCallExpression ( node ) { return node . kind === ts . SyntaxKind . CallExpression ; } export function isCallLikeExpression ( node ) { switch ( node . kind ) { case ts . SyntaxKind . CallExpression : case ts . SyntaxKind . Decorator : case ts . SyntaxKind . JsxOpeningElement : case ts . SyntaxKind . JsxSelfClosingElement : case ts . SyntaxKind . NewExpression : case ts . SyntaxKind . TaggedTemplateExpression : return true ; default : return false ; } } export function isCallSignatureDeclaration ( node ) { return node . kind === ts . SyntaxKind . CallSignature ; } export function isCaseBlock ( node ) { return node . kind === ts . SyntaxKind . CaseBlock ; } export function isCaseClause ( node ) { return node . kind === ts . SyntaxKind . CaseClause ; } export function isCaseOrDefaultClause ( node ) { return node . kind === ts . SyntaxKind . CaseClause || node . kind === ts . SyntaxKind . DefaultClause ; } export function isCatchClause ( node ) { return node . kind === ts . SyntaxKind . CatchClause ; } export function isClassDeclaration ( node ) { return node . kind === ts . SyntaxKind . ClassDeclaration ; } export function isClassExpression ( node ) { return node . kind === ts . SyntaxKind . ClassExpression ; } export function isClassLikeDeclaration ( node ) { return node . kind === ts . SyntaxKind . ClassDeclaration || node . kind === ts . SyntaxKind . ClassExpression ; } export function isCommaListExpression ( node ) { return node . kind === ts . SyntaxKind . CommaListExpression ; } export function isConditionalExpression ( node ) { return node . kind === ts . SyntaxKind . ConditionalExpression ; } export function isConditionalTypeNode ( node ) { return node . kind === ts . SyntaxKind . ConditionalType ; } export function isConstructorDeclaration ( node ) { return node . kind === ts . SyntaxKind . Constructor ; } export function isConstructorTypeNode ( node ) { return node . kind === ts . SyntaxKind . ConstructorType ; } export function isConstructSignatureDeclaration ( node ) { return node . kind === ts . SyntaxKind . ConstructSignature ; } export function isContinueStatement ( node ) { return node . kind === ts . SyntaxKind . ContinueStatement ; } export function isComputedPropertyName ( node ) { return node . kind === ts . SyntaxKind . ComputedPropertyName ; } export function isDebuggerStatement ( node ) { return node . kind === ts . SyntaxKind . DebuggerStatement ; } export function isDecorator ( node ) { return node . kind === ts . SyntaxKind . Decorator ; } export function isDefaultClause ( node ) { return node . kind === ts . SyntaxKind . DefaultClause ; } export function isDeleteExpression ( node ) { return node . kind === ts . SyntaxKind . DeleteExpression ; } export function isDoStatement ( node ) { return node . kind === ts . SyntaxKind . DoStatement ; } export function isElementAccessExpression ( node ) { return node . kind === ts . SyntaxKind . ElementAccessExpression ; } export function isEmptyStatement ( node ) { return node . kind === ts . SyntaxKind . EmptyStatement ; } export function isEntityName ( node ) { return node . kind === ts . SyntaxKind . Identifier || isQualifiedName ( node ) ; } export function isEntityNameExpression ( node ) { return node . kind === ts . SyntaxKind . Identifier || isPropertyAccessExpression ( node ) && isEntityNameExpression ( node . expression ) ; } export function isEnumDeclaration ( node ) { return node . kind === ts . SyntaxKind . EnumDeclaration ; } export function isEnumMember ( node ) { return node . kind === ts . SyntaxKind . EnumMember ; } export function isExportAssignment ( node ) { return node . kind === ts . SyntaxKind . ExportAssignment ; } export function isExportDeclaration ( node ) { return node . kind === ts . SyntaxKind . ExportDeclaration ; } export function isExportSpecifier ( node ) { return node . kind === ts . SyntaxKind . ExportSpecifier ; } export function isExpression ( node ) { switch ( node . kind ) { case ts . SyntaxKind . ArrayLiteralExpression : case ts . SyntaxKind . ArrowFunction : case ts . SyntaxKind . AsExpression : case ts . SyntaxKind . AwaitExpression : case ts . SyntaxKind . BinaryExpression : case ts . SyntaxKind . CallExpression : case ts . SyntaxKind . ClassExpression : case ts . SyntaxKind . CommaListExpression : case ts . SyntaxKind . ConditionalExpression : case ts . SyntaxKind . DeleteExpression : case ts . SyntaxKind . ElementAccessExpression : case ts . SyntaxKind . FalseKeyword : case ts . SyntaxKind . FunctionExpression : case ts . SyntaxKind . Identifier : case ts . SyntaxKind . JsxElement : case ts . SyntaxKind . JsxFragment : case ts . SyntaxKind . JsxExpression : case ts . SyntaxKind . JsxOpeningElement : case ts . SyntaxKind . JsxOpeningFragment : case ts . SyntaxKind . JsxSelfClosingElement : case ts . SyntaxKind . MetaProperty : case ts . SyntaxKind . NewExpression : case ts . SyntaxKind . NonNullExpression : case ts . SyntaxKind . NoSubstitutionTemplateLiteral : case ts . SyntaxKind . NullKeyword : case ts . SyntaxKind . NumericLiteral : case ts . SyntaxKind . ObjectLiteralExpression : case ts . SyntaxKind . OmittedExpression : case ts . SyntaxKind . ParenthesizedExpression : case ts . SyntaxKind . PostfixUnaryExpression : case ts . SyntaxKind . PrefixUnaryExpression : case ts . SyntaxKind . PropertyAccessExpression : case ts . SyntaxKind . RegularExpressionLiteral : case ts . SyntaxKind . SpreadElement : case ts . SyntaxKind . StringLiteral : case ts . SyntaxKind . SuperKeyword : case ts . SyntaxKind . TaggedTemplateExpression : case ts . SyntaxKind . TemplateExpression : case ts . SyntaxKind . ThisKeyword : case ts . SyntaxKind . TrueKeyword : case ts . SyntaxKind . TypeAssertionExpression : case ts . SyntaxKind . TypeOfExpression : case ts . SyntaxKind . VoidExpression : case ts . SyntaxKind . YieldExpression : return true ; default : return false ; } } export function isExpressionStatement ( node ) { return node . kind === ts . SyntaxKind . ExpressionStatement ; } export function isExpressionWithTypeArguments ( node ) { return node . kind === ts . SyntaxKind . ExpressionWithTypeArguments ; } export function isExternalModuleReference ( node ) { return node . kind === ts . SyntaxKind . ExternalModuleReference ; } export function isForInStatement ( node ) { return node . kind === ts . SyntaxKind . ForInStatement ; } export function isForInOrOfStatement ( node ) { return node . kind === ts . SyntaxKind . ForOfStatement || node . kind === ts . SyntaxKind . ForInStatement ; } export function isForOfStatement ( node ) { return node . kind === ts . SyntaxKind . ForOfStatement ; } export function isForStatement ( node ) { return node . kind === ts . SyntaxKind . ForStatement ; } export function isFunctionDeclaration ( node ) { return node . kind === ts . SyntaxKind . FunctionDeclaration ; } export function isFunctionExpression ( node ) { return node . kind === ts . SyntaxKind . FunctionExpression ; } export function isFunctionTypeNode ( node ) { return node . kind === ts . SyntaxKind . FunctionType ; } export function isGetAccessorDeclaration ( node ) { return node . kind === ts . SyntaxKind . GetAccessor ; } export function isIdentifier ( node ) { return node . kind === ts . SyntaxKind . Identifier ; } export function isIfStatement ( node ) { return node . kind === ts . SyntaxKind . IfStatement ; } export function isImportClause ( node ) { return node . kind === ts . SyntaxKind . ImportClause ; } export function isImportDeclaration ( node ) { return node . kind === ts . SyntaxKind . ImportDeclaration ; } export function isImportEqualsDeclaration ( node ) { return node . kind === ts . SyntaxKind . ImportEqualsDeclaration ; } export function isImportSpecifier ( node ) { return node . kind === ts . SyntaxKind . ImportSpecifier ; } export function isIndexedAccessTypeNode ( node ) { return node . kind === ts . SyntaxKind . IndexedAccessType ; } export function isIndexSignatureDeclaration ( node ) { return node . kind === ts . SyntaxKind . IndexSignature ; } export function isInferTypeNode ( node ) { return node . kind === ts . SyntaxKind . InferType ; } export function isInterfaceDeclaration ( node ) { return node . kind === ts . SyntaxKind . InterfaceDeclaration ; } export function isIntersectionTypeNode ( node ) { return node . kind === ts . SyntaxKind . IntersectionType ; } export function isIterationStatement ( node ) { switch ( node . kind ) { case ts . SyntaxKind . ForStatement : case ts . SyntaxKind . ForOfStatement : case ts . SyntaxKind . ForInStatement : case ts . SyntaxKind . WhileStatement : case ts . SyntaxKind . DoStatement : return true ; default : return false ; } } export function isJsDoc ( node ) { return node . kind === ts . SyntaxKind . JSDocComment ; } export function isJsxAttribute ( node ) { return node . kind === ts . SyntaxKind . JsxAttribute ; } export function isJsxAttributeLike ( node ) { return node . kind === ts . SyntaxKind . JsxAttribute || node . kind === ts . SyntaxKind . JsxSpreadAttribute ; } export function isJsxAttributes ( node ) { return node . kind === ts . SyntaxKind . JsxAttributes ; } export function isJsxClosingElement ( node ) { return node . kind === ts . SyntaxKind . JsxClosingElement ; } export function isJsxClosingFragment ( node ) { return node . kind === ts . SyntaxKind . JsxClosingFragment ; } export function isJsxElement ( node ) { return node . kind === ts . SyntaxKind . JsxElement ; } export function isJsxExpression ( node ) { return node . kind === ts . SyntaxKind . JsxExpression ; } export function isJsxFragment ( node ) { return node . kind === ts . SyntaxKind . JsxFragment ; } export function isJsxOpeningElement ( node ) { return node . kind === ts . SyntaxKind . JsxOpeningElement ; } export function isJsxOpeningFragment ( node ) { return node . kind === ts . SyntaxKind . JsxOpeningFragment ; } export function isJsxOpeningLikeElement ( node ) { return node . kind === ts . SyntaxKind . JsxOpeningElement || node . kind === ts . SyntaxKind . JsxSelfClosingElement ; } export function isJsxSelfClosingElement ( node ) { return node . kind === ts . SyntaxKind . JsxSelfClosingElement ; } export function isJsxSpreadAttribute ( node ) { return node . kind === ts . SyntaxKind . JsxSpreadAttribute ; } export function isJsxText ( node ) { return node . kind === ts . SyntaxKind . JsxText ; } export function isLabeledStatement ( node ) { return node . kind === ts . SyntaxKind . LabeledStatement ; } export function isLiteralExpression ( node ) { return node . kind >= ts . SyntaxKind . FirstLiteralToken && node . kind <= ts . SyntaxKind . LastLiteralToken ; } export function isLiteralTypeNode ( node ) { return node . kind === ts . SyntaxKind . LiteralType ; } export function isMappedTypeNode ( node ) { return node . kind === ts . SyntaxKind . MappedType ; } export function isMetaProperty ( node ) { return node . kind === ts . SyntaxKind . MetaProperty ; } export function isMethodDeclaration ( node ) { return node . kind === ts . SyntaxKind . MethodDeclaration ; } export function isMethodSignature ( node ) { return node . kind === ts . SyntaxKind . MethodSignature ; } export function isModuleBlock ( node ) { return node . kind === ts . SyntaxKind . ModuleBlock ; } export function isModuleDeclaration ( node ) { return node . kind === ts . SyntaxKind . ModuleDeclaration ; } export function isNamedExports ( node ) { return node . kind === ts . SyntaxKind . NamedExports ; } export function isNamedImports ( node ) { return node . kind === ts . SyntaxKind . NamedImports ; } export function isNamespaceDeclaration ( node ) { return isModuleDeclaration ( node ) && node . name . kind === ts . SyntaxKind . Identifier && node . body !== undefined && ( node . body . kind === ts . SyntaxKind . ModuleBlock || isNamespaceDeclaration ( node . body ) ) ; } export function isNamespaceImport ( node ) { return node . kind === ts . SyntaxKind . NamespaceImport ; } export function isNamespaceExportDeclaration ( node ) { return node . kind === ts . SyntaxKind . NamespaceExportDeclaration ; } export function isNewExpression ( node ) { return node . kind === ts . SyntaxKind . NewExpression ; } export function isNonNullExpression ( node ) { return node . kind === ts . SyntaxKind . NonNullExpression ; } export function isNoSubstitutionTemplateLiteral ( node ) { return node . kind === ts . SyntaxKind . NoSubstitutionTemplateLiteral ; } export function isNullLiteral ( node ) { return node . kind === ts . SyntaxKind . NullKeyword ; } export function isNumericLiteral ( node ) { return node . kind === ts . SyntaxKind . NumericLiteral ; } export function isNumericOrStringLikeLiteral ( node ) { switch ( node . kind ) { case ts . SyntaxKind . StringLiteral : case ts . SyntaxKind . NumericLiteral : case ts . SyntaxKind . NoSubstitutionTemplateLiteral : return true ; default : return false ; } } export function isObjectBindingPattern ( node ) { return node . kind === ts . SyntaxKind . ObjectBindingPattern ; } export function isObjectLiteralExpression ( node ) { return node . kind === ts . SyntaxKind . ObjectLiteralExpression ; } export function isOmittedExpression ( node ) { return node . kind === ts . SyntaxKind . OmittedExpression ; } export function isParameterDeclaration ( node ) { return node . kind === ts . SyntaxKind . Parameter ; } export function isParenthesizedExpression ( node ) { return node . kind === ts . SyntaxKind . ParenthesizedExpression ; } export function isParenthesizedTypeNode ( node ) { return node . kind === ts . SyntaxKind . ParenthesizedType ; } export function isPostfixUnaryExpression ( node ) { return node . kind === ts . SyntaxKind . PostfixUnaryExpression ; } export function isPrefixUnaryExpression ( node ) { return node . kind === ts . SyntaxKind . PrefixUnaryExpression ; } export function isPropertyAccessExpression ( node ) { return node . kind === ts . SyntaxKind . PropertyAccessExpression ; } export function isPropertyAssignment ( node ) { return node . kind === ts . SyntaxKind . PropertyAssignment ; } export function isPropertyDeclaration ( node ) { return node . kind === ts . SyntaxKind . PropertyDeclaration ; } export function isPropertySignature ( node ) { return node . kind === ts . SyntaxKind . PropertySignature ; } export function isQualifiedName ( node ) { return node . kind === ts . SyntaxKind . QualifiedName ; } export function isRegularExpressionLiteral ( node ) { return node . kind === ts . SyntaxKind . RegularExpressionLiteral ; } export function isReturnStatement ( node ) { return node . kind === ts . SyntaxKind . ReturnStatement ; } export function isSetAccessorDeclaration ( node ) { return node . kind === ts . SyntaxKind . SetAccessor ; } export function isShorthandPropertyAssignment ( node ) { return node . kind === ts . SyntaxKind . ShorthandPropertyAssignment ; } export function isSignatureDeclaration ( node ) { return ( < any > node ) . parameters !== undefined ; } export function isSourceFile ( node ) { return node . kind === ts . SyntaxKind . SourceFile ; } export function isSpreadAssignment ( node ) { return node . kind === ts . SyntaxKind . SpreadAssignment ; } export function isSpreadElement ( node ) { return node . kind === ts . SyntaxKind . SpreadElement ; } export function isStringLiteral ( node ) { return node . kind === ts . SyntaxKind . StringLiteral ; } export function isSwitchStatement ( node ) { return node . kind === ts . SyntaxKind . SwitchStatement ; } export function isSyntaxList ( node ) { return node . kind === ts . SyntaxKind . SyntaxList ; } export function isTaggedTemplateExpression ( node ) { return node . kind === ts . SyntaxKind . TaggedTemplateExpression ; } export function isTemplateExpression ( node ) { return node . kind === ts . SyntaxKind . TemplateExpression ; } export function isTemplateLiteral ( node ) { return node . kind === ts . SyntaxKind . TemplateExpression || node . kind === ts . SyntaxKind . NoSubstitutionTemplateLiteral ; } export function isTextualLiteral ( node ) { return node . kind === ts . SyntaxKind . StringLiteral || node . kind === ts . SyntaxKind . NoSubstitutionTemplateLiteral ; } export function isThrowStatement ( node ) { return node . kind === ts . SyntaxKind . ThrowStatement ; } export function isTryStatement ( node ) { return node . kind === ts . SyntaxKind . TryStatement ; } export function isTupleTypeNode ( node ) { return node . kind === ts . SyntaxKind . TupleType ; } export function isTypeAliasDeclaration ( node ) { return node . kind === ts . SyntaxKind . TypeAliasDeclaration ; } export function isTypeAssertion ( node ) { return node . kind === ts . SyntaxKind . TypeAssertionExpression ; } export function isTypeLiteralNode ( node ) { return node . kind === ts . SyntaxKind . TypeLiteral ; } export function isTypeOfExpression ( node ) { return node . kind === ts . SyntaxKind . TypeOfExpression ; } export function isTypeOperatorNode ( node ) { return node . kind === ts . SyntaxKind . TypeOperator ; } export function isTypeParameterDeclaration ( node ) { return node . kind === ts . SyntaxKind . TypeParameter ; } export function isTypePredicateNode ( node ) { return node . kind === ts . SyntaxKind . TypePredicate ; } export function isTypeReferenceNode ( node ) { return node . kind === ts . SyntaxKind . TypeReference ; } export function isTypeQueryNode ( node ) { return node . kind === ts . SyntaxKind . TypeQuery ; } export function isUnionTypeNode ( node ) { return node . kind === ts . SyntaxKind . UnionType ; } export function isVariableDeclaration ( node ) { return node . kind === ts . SyntaxKind . VariableDeclaration ; } export function isVariableStatement ( node ) { return node . kind === ts . SyntaxKind . VariableStatement ; } export function isVariableDeclarationList ( node ) { return node . kind === ts . SyntaxKind . VariableDeclarationList ; } export function isVoidExpression ( node ) { return node . kind === ts . SyntaxKind . VoidExpression ; } export function isWhileStatement ( node ) { return node . kind === ts . SyntaxKind . WhileStatement ; } export function isWithStatement ( node ) { return node . kind === ts . SyntaxKind . WithStatement ; }