1import { 2 AbstractKeyword, AccessorKeyword, Annotation, AnnotationDeclaration, AnnotationPropertyDeclaration, ArrayBindingPattern, 3 ArrayLiteralExpression, ArrayTypeNode, ArrowFunction, AsExpression, AssertClause, AssertEntry, AssertsKeyword, 4 AsteriskToken, AsyncKeyword, AwaitExpression, AwaitKeyword, BigIntLiteral, BinaryExpression, BindingElement, 5 Block, BreakStatement, Bundle, CallExpression, CallSignatureDeclaration, CaseBlock, CaseClause, CatchClause, 6 ClassDeclaration, ClassExpression, ClassStaticBlockDeclaration, ColonToken, CommaListExpression, ComputedPropertyName, 7 ConditionalExpression, ConditionalTypeNode, ConstructorDeclaration, ConstructorTypeNode, ConstructSignatureDeclaration, 8 ContinueStatement, DebuggerStatement, Decorator, DefaultClause, DeleteExpression, DoStatement, DotDotDotToken, ElementAccessExpression, 9 EmptyStatement, EndOfDeclarationMarker, EnumDeclaration, EnumMember, EqualsGreaterThanToken, EtsComponentExpression, 10 ExclamationToken, ExportAssignment, ExportDeclaration, ExportKeyword, ExportSpecifier, ExpressionStatement, 11 ExpressionWithTypeArguments, ExternalModuleReference, ForInStatement, ForOfStatement, ForStatement, 12 FunctionDeclaration, FunctionExpression, FunctionTypeNode, GetAccessorDeclaration, HeritageClause, Identifier, 13 IfStatement, ImportClause, ImportDeclaration, ImportEqualsDeclaration, ImportExpression, ImportSpecifier, 14 ImportTypeAssertionContainer, ImportTypeNode, IndexedAccessTypeNode, IndexSignatureDeclaration, InferTypeNode, 15 InterfaceDeclaration, IntersectionTypeNode, JSDoc, JSDocAllType, JSDocAugmentsTag, JSDocAuthorTag, JSDocCallbackTag, 16 JSDocClassTag, JSDocDeprecatedTag, JSDocEnumTag, JSDocFunctionType, JSDocImplementsTag, JSDocLink, JSDocLinkCode, 17 JSDocLinkPlain, JSDocMemberName, JSDocNamepathType, JSDocNameReference, JSDocNonNullableType, JSDocNullableType, 18 JSDocOptionalType, JSDocOverrideTag, JSDocParameterTag, JSDocPrivateTag, JSDocPropertyTag, JSDocProtectedTag, 19 JSDocPublicTag, JSDocReadonlyTag, JSDocReturnTag, JSDocSeeTag, JSDocSignature, JSDocTemplateTag, JSDocThisTag, 20 JSDocTypedefTag, JSDocTypeExpression, JSDocTypeLiteral, JSDocTypeTag, JSDocUnknownTag, JSDocUnknownType, 21 JSDocVariadicType, JsxAttribute, JsxAttributes, JsxClosingElement, JsxClosingFragment, JsxElement, JsxExpression, 22 JsxFragment, JsxOpeningElement, JsxOpeningFragment, JsxSelfClosingElement, JsxSpreadAttribute, JsxText, 23 LabeledStatement, LiteralTypeNode, MappedTypeNode, MergeDeclarationMarker, MetaProperty, MethodDeclaration, 24 MethodSignature, MinusToken, MissingDeclaration, ModuleBlock, ModuleDeclaration, NamedExports, NamedImports, 25 NamedTupleMember, NamespaceExport, NamespaceExportDeclaration, NamespaceImport, NewExpression, Node, 26 NonNullExpression, NoSubstitutionTemplateLiteral, NotEmittedStatement, NumericLiteral, ObjectBindingPattern, 27 ObjectLiteralExpression, OmittedExpression, OptionalTypeNode, OverrideKeyword, ParameterDeclaration, 28 ParenthesizedExpression, ParenthesizedTypeNode, PartiallyEmittedExpression, PlusToken, PostfixUnaryExpression, 29 PrefixUnaryExpression, PrivateIdentifier, PropertyAccessExpression, PropertyAssignment, PropertyDeclaration, 30 PropertySignature, QualifiedName, QuestionDotToken, QuestionToken, ReadonlyKeyword, RegularExpressionLiteral, 31 RestTypeNode, ReturnStatement, SatisfiesExpression, SemicolonClassElement, SetAccessorDeclaration, 32 ShorthandPropertyAssignment, SourceFile, SpreadAssignment, SpreadElement, StaticKeyword, StringLiteral, 33 StructDeclaration, SuperExpression, SwitchStatement, SyntaxKind, SyntaxList, SyntheticExpression, 34 SyntheticReferenceExpression, TaggedTemplateExpression, TemplateExpression, TemplateHead, TemplateLiteralTypeNode, 35 TemplateLiteralTypeSpan, TemplateMiddle, TemplateSpan, TemplateTail, ThisTypeNode, ThrowStatement, Token, 36 TryStatement, TupleTypeNode, TypeAliasDeclaration, TypeAssertion, TypeLiteralNode, TypeOfExpression, 37 TypeOperatorNode, TypeParameterDeclaration, TypePredicateNode, TypeQueryNode, TypeReferenceNode, UnionTypeNode, 38 UnparsedPrepend, UnparsedSource, VariableDeclaration, VariableDeclarationList, VariableStatement, VoidExpression, 39 WhileStatement, WithStatement, YieldExpression, 40} from "../_namespaces/ts"; 41 42// Literals 43 44export function isNumericLiteral(node: Node): node is NumericLiteral { 45 return node.kind === SyntaxKind.NumericLiteral; 46} 47 48export function isBigIntLiteral(node: Node): node is BigIntLiteral { 49 return node.kind === SyntaxKind.BigIntLiteral; 50} 51 52export function isStringLiteral(node: Node): node is StringLiteral { 53 return node.kind === SyntaxKind.StringLiteral; 54} 55 56export function isJsxText(node: Node): node is JsxText { 57 return node.kind === SyntaxKind.JsxText; 58} 59 60export function isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral { 61 return node.kind === SyntaxKind.RegularExpressionLiteral; 62} 63 64export function isNoSubstitutionTemplateLiteral(node: Node): node is NoSubstitutionTemplateLiteral { 65 return node.kind === SyntaxKind.NoSubstitutionTemplateLiteral; 66} 67 68// Pseudo-literals 69 70export function isTemplateHead(node: Node): node is TemplateHead { 71 return node.kind === SyntaxKind.TemplateHead; 72} 73 74export function isTemplateMiddle(node: Node): node is TemplateMiddle { 75 return node.kind === SyntaxKind.TemplateMiddle; 76} 77 78export function isTemplateTail(node: Node): node is TemplateTail { 79 return node.kind === SyntaxKind.TemplateTail; 80} 81 82// Punctuation 83 84export function isDotDotDotToken(node: Node): node is DotDotDotToken { 85 return node.kind === SyntaxKind.DotDotDotToken; 86} 87 88/** @internal */ 89export function isCommaToken(node: Node): node is Token<SyntaxKind.CommaToken> { 90 return node.kind === SyntaxKind.CommaToken; 91} 92 93export function isPlusToken(node: Node): node is PlusToken { 94 return node.kind === SyntaxKind.PlusToken; 95} 96 97export function isMinusToken(node: Node): node is MinusToken { 98 return node.kind === SyntaxKind.MinusToken; 99} 100 101export function isAsteriskToken(node: Node): node is AsteriskToken { 102 return node.kind === SyntaxKind.AsteriskToken; 103} 104 105/** @internal */ 106export function isExclamationToken(node: Node): node is ExclamationToken { 107 return node.kind === SyntaxKind.ExclamationToken; 108} 109 110/** @internal */ 111export function isQuestionToken(node: Node): node is QuestionToken { 112 return node.kind === SyntaxKind.QuestionToken; 113} 114 115/** @internal */ 116export function isColonToken(node: Node): node is ColonToken { 117 return node.kind === SyntaxKind.ColonToken; 118} 119 120/** @internal */ 121export function isQuestionDotToken(node: Node): node is QuestionDotToken { 122 return node.kind === SyntaxKind.QuestionDotToken; 123} 124 125/** @internal */ 126export function isEqualsGreaterThanToken(node: Node): node is EqualsGreaterThanToken { 127 return node.kind === SyntaxKind.EqualsGreaterThanToken; 128} 129 130// Identifiers 131 132export function isIdentifier(node: Node): node is Identifier { 133 return node.kind === SyntaxKind.Identifier; 134} 135 136export function isPrivateIdentifier(node: Node): node is PrivateIdentifier { 137 return node.kind === SyntaxKind.PrivateIdentifier; 138} 139 140// Reserved Words 141 142/** @internal */ 143export function isExportModifier(node: Node): node is ExportKeyword { 144 return node.kind === SyntaxKind.ExportKeyword; 145} 146 147/** @internal */ 148export function isAsyncModifier(node: Node): node is AsyncKeyword { 149 return node.kind === SyntaxKind.AsyncKeyword; 150} 151 152/** @internal */ 153export function isAssertsKeyword(node: Node): node is AssertsKeyword { 154 return node.kind === SyntaxKind.AssertsKeyword; 155} 156 157/** @internal */ 158export function isAwaitKeyword(node: Node): node is AwaitKeyword { 159 return node.kind === SyntaxKind.AwaitKeyword; 160} 161 162/** @internal */ 163export function isReadonlyKeyword(node: Node): node is ReadonlyKeyword { 164 return node.kind === SyntaxKind.ReadonlyKeyword; 165} 166 167/** @internal */ 168export function isStaticModifier(node: Node): node is StaticKeyword { 169 return node.kind === SyntaxKind.StaticKeyword; 170} 171 172/** @internal */ 173export function isAbstractModifier(node: Node): node is AbstractKeyword { 174 return node.kind === SyntaxKind.AbstractKeyword; 175} 176 177/** @internal */ 178export function isOverrideModifier(node: Node): node is OverrideKeyword { 179 return node.kind === SyntaxKind.OverrideKeyword; 180} 181 182/** @internal */ 183export function isAccessorModifier(node: Node): node is AccessorKeyword { 184 return node.kind === SyntaxKind.AccessorKeyword; 185} 186 187/** @internal */ 188export function isSuperKeyword(node: Node): node is SuperExpression { 189 return node.kind === SyntaxKind.SuperKeyword; 190} 191 192/** @internal */ 193export function isImportKeyword(node: Node): node is ImportExpression { 194 return node.kind === SyntaxKind.ImportKeyword; 195} 196 197// Names 198 199export function isQualifiedName(node: Node): node is QualifiedName { 200 return node.kind === SyntaxKind.QualifiedName; 201} 202 203export function isComputedPropertyName(node: Node): node is ComputedPropertyName { 204 return node.kind === SyntaxKind.ComputedPropertyName; 205} 206 207// Signature elements 208 209export function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration { 210 return node.kind === SyntaxKind.TypeParameter; 211} 212 213// TODO(rbuckton): Rename to 'isParameterDeclaration' 214export function isParameter(node: Node): node is ParameterDeclaration { 215 return node.kind === SyntaxKind.Parameter; 216} 217 218export function isDecoratorOrAnnotation(node: Node): node is Decorator { 219 return node.kind === SyntaxKind.Decorator; 220} 221 222export function isDecorator(node: Node): node is Decorator { 223 return node.kind === SyntaxKind.Decorator && (node as Decorator).annotationDeclaration === undefined; 224} 225 226export function isAnnotation(node: Node): node is Annotation { 227 return node.kind === SyntaxKind.Decorator && (node as Annotation).annotationDeclaration !== undefined; 228} 229 230// TypeMember 231 232export function isPropertySignature(node: Node): node is PropertySignature { 233 return node.kind === SyntaxKind.PropertySignature; 234} 235 236export function isPropertyDeclaration(node: Node): node is PropertyDeclaration { 237 return node.kind === SyntaxKind.PropertyDeclaration; 238} 239 240export function isAnnotationPropertyDeclaration(node: Node): node is AnnotationPropertyDeclaration { 241 return node.kind === SyntaxKind.AnnotationPropertyDeclaration; 242} 243 244export function isMethodSignature(node: Node): node is MethodSignature { 245 return node.kind === SyntaxKind.MethodSignature; 246} 247 248export function isMethodDeclaration(node: Node): node is MethodDeclaration { 249 return node.kind === SyntaxKind.MethodDeclaration; 250} 251 252export function isClassStaticBlockDeclaration(node: Node): node is ClassStaticBlockDeclaration { 253 return node.kind === SyntaxKind.ClassStaticBlockDeclaration; 254} 255 256export function isConstructorDeclaration(node: Node): node is ConstructorDeclaration { 257 return node.kind === SyntaxKind.Constructor; 258} 259 260export function isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration { 261 return node.kind === SyntaxKind.GetAccessor; 262} 263 264export function isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration { 265 return node.kind === SyntaxKind.SetAccessor; 266} 267 268export function isCallSignatureDeclaration(node: Node): node is CallSignatureDeclaration { 269 return node.kind === SyntaxKind.CallSignature; 270} 271 272export function isConstructSignatureDeclaration(node: Node): node is ConstructSignatureDeclaration { 273 return node.kind === SyntaxKind.ConstructSignature; 274} 275 276export function isIndexSignatureDeclaration(node: Node): node is IndexSignatureDeclaration { 277 return node.kind === SyntaxKind.IndexSignature; 278} 279 280// Type 281 282export function isTypePredicateNode(node: Node): node is TypePredicateNode { 283 return node.kind === SyntaxKind.TypePredicate; 284} 285 286export function isTypeReferenceNode(node: Node): node is TypeReferenceNode { 287 return node.kind === SyntaxKind.TypeReference; 288} 289 290export function isFunctionTypeNode(node: Node): node is FunctionTypeNode { 291 return node.kind === SyntaxKind.FunctionType; 292} 293 294export function isConstructorTypeNode(node: Node): node is ConstructorTypeNode { 295 return node.kind === SyntaxKind.ConstructorType; 296} 297 298export function isTypeQueryNode(node: Node): node is TypeQueryNode { 299 return node.kind === SyntaxKind.TypeQuery; 300} 301 302export function isTypeLiteralNode(node: Node): node is TypeLiteralNode { 303 return node.kind === SyntaxKind.TypeLiteral; 304} 305 306export function isArrayTypeNode(node: Node): node is ArrayTypeNode { 307 return node.kind === SyntaxKind.ArrayType; 308} 309 310export function isTupleTypeNode(node: Node): node is TupleTypeNode { 311 return node.kind === SyntaxKind.TupleType; 312} 313 314export function isNamedTupleMember(node: Node): node is NamedTupleMember { 315 return node.kind === SyntaxKind.NamedTupleMember; 316} 317 318export function isOptionalTypeNode(node: Node): node is OptionalTypeNode { 319 return node.kind === SyntaxKind.OptionalType; 320} 321 322export function isRestTypeNode(node: Node): node is RestTypeNode { 323 return node.kind === SyntaxKind.RestType; 324} 325 326export function isUnionTypeNode(node: Node): node is UnionTypeNode { 327 return node.kind === SyntaxKind.UnionType; 328} 329 330export function isIntersectionTypeNode(node: Node): node is IntersectionTypeNode { 331 return node.kind === SyntaxKind.IntersectionType; 332} 333 334export function isConditionalTypeNode(node: Node): node is ConditionalTypeNode { 335 return node.kind === SyntaxKind.ConditionalType; 336} 337 338export function isInferTypeNode(node: Node): node is InferTypeNode { 339 return node.kind === SyntaxKind.InferType; 340} 341 342export function isParenthesizedTypeNode(node: Node): node is ParenthesizedTypeNode { 343 return node.kind === SyntaxKind.ParenthesizedType; 344} 345 346export function isThisTypeNode(node: Node): node is ThisTypeNode { 347 return node.kind === SyntaxKind.ThisType; 348} 349 350export function isTypeOperatorNode(node: Node): node is TypeOperatorNode { 351 return node.kind === SyntaxKind.TypeOperator; 352} 353 354export function isIndexedAccessTypeNode(node: Node): node is IndexedAccessTypeNode { 355 return node.kind === SyntaxKind.IndexedAccessType; 356} 357 358export function isMappedTypeNode(node: Node): node is MappedTypeNode { 359 return node.kind === SyntaxKind.MappedType; 360} 361 362export function isLiteralTypeNode(node: Node): node is LiteralTypeNode { 363 return node.kind === SyntaxKind.LiteralType; 364} 365 366export function isImportTypeNode(node: Node): node is ImportTypeNode { 367 return node.kind === SyntaxKind.ImportType; 368} 369 370export function isTemplateLiteralTypeSpan(node: Node): node is TemplateLiteralTypeSpan { 371 return node.kind === SyntaxKind.TemplateLiteralTypeSpan; 372} 373 374export function isTemplateLiteralTypeNode(node: Node): node is TemplateLiteralTypeNode { 375 return node.kind === SyntaxKind.TemplateLiteralType; 376} 377 378// Binding patterns 379 380export function isObjectBindingPattern(node: Node): node is ObjectBindingPattern { 381 return node.kind === SyntaxKind.ObjectBindingPattern; 382} 383 384export function isArrayBindingPattern(node: Node): node is ArrayBindingPattern { 385 return node.kind === SyntaxKind.ArrayBindingPattern; 386} 387 388export function isBindingElement(node: Node): node is BindingElement { 389 return node.kind === SyntaxKind.BindingElement; 390} 391 392// Expression 393 394export function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression { 395 return node.kind === SyntaxKind.ArrayLiteralExpression; 396} 397 398export function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression { 399 return node.kind === SyntaxKind.ObjectLiteralExpression; 400} 401 402export function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression { 403 return node.kind === SyntaxKind.PropertyAccessExpression; 404} 405 406export function isElementAccessExpression(node: Node): node is ElementAccessExpression { 407 return node.kind === SyntaxKind.ElementAccessExpression; 408} 409 410export function isCallExpression(node: Node): node is CallExpression { 411 return node.kind === SyntaxKind.CallExpression; 412} 413 414export function isNewExpression(node: Node): node is NewExpression { 415 return node.kind === SyntaxKind.NewExpression; 416} 417 418export function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression { 419 return node.kind === SyntaxKind.TaggedTemplateExpression; 420} 421 422export function isTypeAssertionExpression(node: Node): node is TypeAssertion { 423 return node.kind === SyntaxKind.TypeAssertionExpression; 424} 425 426export function isParenthesizedExpression(node: Node): node is ParenthesizedExpression { 427 return node.kind === SyntaxKind.ParenthesizedExpression; 428} 429 430export function isFunctionExpression(node: Node): node is FunctionExpression { 431 return node.kind === SyntaxKind.FunctionExpression; 432} 433 434export function isEtsComponentExpression(node: Node): node is EtsComponentExpression { 435 return node.kind === SyntaxKind.EtsComponentExpression; 436} 437 438export function isArrowFunction(node: Node): node is ArrowFunction { 439 return node.kind === SyntaxKind.ArrowFunction; 440} 441 442export function isDeleteExpression(node: Node): node is DeleteExpression { 443 return node.kind === SyntaxKind.DeleteExpression; 444} 445 446export function isTypeOfExpression(node: Node): node is TypeOfExpression { 447 return node.kind === SyntaxKind.TypeOfExpression; 448} 449 450export function isVoidExpression(node: Node): node is VoidExpression { 451 return node.kind === SyntaxKind.VoidExpression; 452} 453 454export function isAwaitExpression(node: Node): node is AwaitExpression { 455 return node.kind === SyntaxKind.AwaitExpression; 456} 457 458export function isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression { 459 return node.kind === SyntaxKind.PrefixUnaryExpression; 460} 461 462export function isPostfixUnaryExpression(node: Node): node is PostfixUnaryExpression { 463 return node.kind === SyntaxKind.PostfixUnaryExpression; 464} 465 466export function isBinaryExpression(node: Node): node is BinaryExpression { 467 return node.kind === SyntaxKind.BinaryExpression; 468} 469 470export function isConditionalExpression(node: Node): node is ConditionalExpression { 471 return node.kind === SyntaxKind.ConditionalExpression; 472} 473 474export function isTemplateExpression(node: Node): node is TemplateExpression { 475 return node.kind === SyntaxKind.TemplateExpression; 476} 477 478export function isYieldExpression(node: Node): node is YieldExpression { 479 return node.kind === SyntaxKind.YieldExpression; 480} 481 482export function isSpreadElement(node: Node): node is SpreadElement { 483 return node.kind === SyntaxKind.SpreadElement; 484} 485 486export function isClassExpression(node: Node): node is ClassExpression { 487 return node.kind === SyntaxKind.ClassExpression; 488} 489 490export function isOmittedExpression(node: Node): node is OmittedExpression { 491 return node.kind === SyntaxKind.OmittedExpression; 492} 493 494export function isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments { 495 return node.kind === SyntaxKind.ExpressionWithTypeArguments; 496} 497 498export function isAsExpression(node: Node): node is AsExpression { 499 return node.kind === SyntaxKind.AsExpression; 500} 501 502export function isSatisfiesExpression(node: Node): node is SatisfiesExpression { 503 return node.kind === SyntaxKind.SatisfiesExpression; 504} 505 506export function isNonNullExpression(node: Node): node is NonNullExpression { 507 return node.kind === SyntaxKind.NonNullExpression; 508} 509 510export function isMetaProperty(node: Node): node is MetaProperty { 511 return node.kind === SyntaxKind.MetaProperty; 512} 513 514export function isSyntheticExpression(node: Node): node is SyntheticExpression { 515 return node.kind === SyntaxKind.SyntheticExpression; 516} 517 518export function isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression { 519 return node.kind === SyntaxKind.PartiallyEmittedExpression; 520} 521 522export function isCommaListExpression(node: Node): node is CommaListExpression { 523 return node.kind === SyntaxKind.CommaListExpression; 524} 525 526// Misc 527 528export function isTemplateSpan(node: Node): node is TemplateSpan { 529 return node.kind === SyntaxKind.TemplateSpan; 530} 531 532export function isSemicolonClassElement(node: Node): node is SemicolonClassElement { 533 return node.kind === SyntaxKind.SemicolonClassElement; 534} 535 536// Elements 537 538export function isBlock(node: Node): node is Block { 539 return node.kind === SyntaxKind.Block; 540} 541 542export function isVariableStatement(node: Node): node is VariableStatement { 543 return node.kind === SyntaxKind.VariableStatement; 544} 545 546export function isEmptyStatement(node: Node): node is EmptyStatement { 547 return node.kind === SyntaxKind.EmptyStatement; 548} 549 550export function isExpressionStatement(node: Node): node is ExpressionStatement { 551 return node.kind === SyntaxKind.ExpressionStatement; 552} 553 554export function isIfStatement(node: Node): node is IfStatement { 555 return node.kind === SyntaxKind.IfStatement; 556} 557 558export function isDoStatement(node: Node): node is DoStatement { 559 return node.kind === SyntaxKind.DoStatement; 560} 561 562export function isWhileStatement(node: Node): node is WhileStatement { 563 return node.kind === SyntaxKind.WhileStatement; 564} 565 566export function isForStatement(node: Node): node is ForStatement { 567 return node.kind === SyntaxKind.ForStatement; 568} 569 570export function isForInStatement(node: Node): node is ForInStatement { 571 return node.kind === SyntaxKind.ForInStatement; 572} 573 574export function isForOfStatement(node: Node): node is ForOfStatement { 575 return node.kind === SyntaxKind.ForOfStatement; 576} 577 578export function isContinueStatement(node: Node): node is ContinueStatement { 579 return node.kind === SyntaxKind.ContinueStatement; 580} 581 582export function isBreakStatement(node: Node): node is BreakStatement { 583 return node.kind === SyntaxKind.BreakStatement; 584} 585 586export function isReturnStatement(node: Node): node is ReturnStatement { 587 return node.kind === SyntaxKind.ReturnStatement; 588} 589 590export function isWithStatement(node: Node): node is WithStatement { 591 return node.kind === SyntaxKind.WithStatement; 592} 593 594export function isSwitchStatement(node: Node): node is SwitchStatement { 595 return node.kind === SyntaxKind.SwitchStatement; 596} 597 598export function isLabeledStatement(node: Node): node is LabeledStatement { 599 return node.kind === SyntaxKind.LabeledStatement; 600} 601 602export function isThrowStatement(node: Node): node is ThrowStatement { 603 return node.kind === SyntaxKind.ThrowStatement; 604} 605 606export function isTryStatement(node: Node): node is TryStatement { 607 return node.kind === SyntaxKind.TryStatement; 608} 609 610export function isDebuggerStatement(node: Node): node is DebuggerStatement { 611 return node.kind === SyntaxKind.DebuggerStatement; 612} 613 614export function isVariableDeclaration(node: Node): node is VariableDeclaration { 615 return node.kind === SyntaxKind.VariableDeclaration; 616} 617 618export function isVariableDeclarationList(node: Node): node is VariableDeclarationList { 619 return node.kind === SyntaxKind.VariableDeclarationList; 620} 621 622export function isFunctionDeclaration(node: Node): node is FunctionDeclaration { 623 return node.kind === SyntaxKind.FunctionDeclaration; 624} 625 626export function isClassDeclaration(node: Node): node is ClassDeclaration { 627 return node.kind === SyntaxKind.ClassDeclaration; 628} 629 630export function isStructDeclaration(node: Node): node is StructDeclaration { 631 return node.kind === SyntaxKind.StructDeclaration; 632} 633 634export function isAnnotationDeclaration(node: Node): node is AnnotationDeclaration { 635 return node.kind === SyntaxKind.AnnotationDeclaration; 636} 637 638export function isInterfaceDeclaration(node: Node): node is InterfaceDeclaration { 639 return node.kind === SyntaxKind.InterfaceDeclaration; 640} 641 642export function isTypeAliasDeclaration(node: Node): node is TypeAliasDeclaration { 643 return node.kind === SyntaxKind.TypeAliasDeclaration; 644} 645 646export function isEnumDeclaration(node: Node): node is EnumDeclaration { 647 return node.kind === SyntaxKind.EnumDeclaration; 648} 649 650export function isModuleDeclaration(node: Node): node is ModuleDeclaration { 651 return node.kind === SyntaxKind.ModuleDeclaration; 652} 653 654export function isModuleBlock(node: Node): node is ModuleBlock { 655 return node.kind === SyntaxKind.ModuleBlock; 656} 657 658export function isCaseBlock(node: Node): node is CaseBlock { 659 return node.kind === SyntaxKind.CaseBlock; 660} 661 662export function isNamespaceExportDeclaration(node: Node): node is NamespaceExportDeclaration { 663 return node.kind === SyntaxKind.NamespaceExportDeclaration; 664} 665 666export function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration { 667 return node.kind === SyntaxKind.ImportEqualsDeclaration; 668} 669 670export function isImportDeclaration(node: Node): node is ImportDeclaration { 671 return node.kind === SyntaxKind.ImportDeclaration; 672} 673 674export function isImportClause(node: Node): node is ImportClause { 675 return node.kind === SyntaxKind.ImportClause; 676} 677 678export function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer { 679 return node.kind === SyntaxKind.ImportTypeAssertionContainer; 680} 681 682export function isAssertClause(node: Node): node is AssertClause { 683 return node.kind === SyntaxKind.AssertClause; 684} 685 686export function isAssertEntry(node: Node): node is AssertEntry { 687 return node.kind === SyntaxKind.AssertEntry; 688} 689 690export function isNamespaceImport(node: Node): node is NamespaceImport { 691 return node.kind === SyntaxKind.NamespaceImport; 692} 693 694export function isNamespaceExport(node: Node): node is NamespaceExport { 695 return node.kind === SyntaxKind.NamespaceExport; 696} 697 698export function isNamedImports(node: Node): node is NamedImports { 699 return node.kind === SyntaxKind.NamedImports; 700} 701 702export function isImportSpecifier(node: Node): node is ImportSpecifier { 703 return node.kind === SyntaxKind.ImportSpecifier; 704} 705 706export function isExportAssignment(node: Node): node is ExportAssignment { 707 return node.kind === SyntaxKind.ExportAssignment; 708} 709 710export function isExportDeclaration(node: Node): node is ExportDeclaration { 711 return node.kind === SyntaxKind.ExportDeclaration; 712} 713 714export function isNamedExports(node: Node): node is NamedExports { 715 return node.kind === SyntaxKind.NamedExports; 716} 717 718export function isExportSpecifier(node: Node): node is ExportSpecifier { 719 return node.kind === SyntaxKind.ExportSpecifier; 720} 721 722export function isMissingDeclaration(node: Node): node is MissingDeclaration { 723 return node.kind === SyntaxKind.MissingDeclaration; 724} 725 726export function isNotEmittedStatement(node: Node): node is NotEmittedStatement { 727 return node.kind === SyntaxKind.NotEmittedStatement; 728} 729 730/** @internal */ 731export function isSyntheticReference(node: Node): node is SyntheticReferenceExpression { 732 return node.kind === SyntaxKind.SyntheticReferenceExpression; 733} 734 735/** @internal */ 736export function isMergeDeclarationMarker(node: Node): node is MergeDeclarationMarker { 737 return node.kind === SyntaxKind.MergeDeclarationMarker; 738} 739 740/** @internal */ 741export function isEndOfDeclarationMarker(node: Node): node is EndOfDeclarationMarker { 742 return node.kind === SyntaxKind.EndOfDeclarationMarker; 743} 744 745// Module References 746 747export function isExternalModuleReference(node: Node): node is ExternalModuleReference { 748 return node.kind === SyntaxKind.ExternalModuleReference; 749} 750 751// JSX 752 753export function isJsxElement(node: Node): node is JsxElement { 754 return node.kind === SyntaxKind.JsxElement; 755} 756 757export function isJsxSelfClosingElement(node: Node): node is JsxSelfClosingElement { 758 return node.kind === SyntaxKind.JsxSelfClosingElement; 759} 760 761export function isJsxOpeningElement(node: Node): node is JsxOpeningElement { 762 return node.kind === SyntaxKind.JsxOpeningElement; 763} 764 765export function isJsxClosingElement(node: Node): node is JsxClosingElement { 766 return node.kind === SyntaxKind.JsxClosingElement; 767} 768 769export function isJsxFragment(node: Node): node is JsxFragment { 770 return node.kind === SyntaxKind.JsxFragment; 771} 772 773export function isJsxOpeningFragment(node: Node): node is JsxOpeningFragment { 774 return node.kind === SyntaxKind.JsxOpeningFragment; 775} 776 777export function isJsxClosingFragment(node: Node): node is JsxClosingFragment { 778 return node.kind === SyntaxKind.JsxClosingFragment; 779} 780 781export function isJsxAttribute(node: Node): node is JsxAttribute { 782 return node.kind === SyntaxKind.JsxAttribute; 783} 784 785export function isJsxAttributes(node: Node): node is JsxAttributes { 786 return node.kind === SyntaxKind.JsxAttributes; 787} 788 789export function isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute { 790 return node.kind === SyntaxKind.JsxSpreadAttribute; 791} 792 793export function isJsxExpression(node: Node): node is JsxExpression { 794 return node.kind === SyntaxKind.JsxExpression; 795} 796 797// Clauses 798 799export function isCaseClause(node: Node): node is CaseClause { 800 return node.kind === SyntaxKind.CaseClause; 801} 802 803export function isDefaultClause(node: Node): node is DefaultClause { 804 return node.kind === SyntaxKind.DefaultClause; 805} 806 807export function isHeritageClause(node: Node): node is HeritageClause { 808 return node.kind === SyntaxKind.HeritageClause; 809} 810 811export function isCatchClause(node: Node): node is CatchClause { 812 return node.kind === SyntaxKind.CatchClause; 813} 814 815// Property assignments 816 817export function isPropertyAssignment(node: Node): node is PropertyAssignment { 818 return node.kind === SyntaxKind.PropertyAssignment; 819} 820 821export function isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment { 822 return node.kind === SyntaxKind.ShorthandPropertyAssignment; 823} 824 825export function isSpreadAssignment(node: Node): node is SpreadAssignment { 826 return node.kind === SyntaxKind.SpreadAssignment; 827} 828 829// Enum 830 831export function isEnumMember(node: Node): node is EnumMember { 832 return node.kind === SyntaxKind.EnumMember; 833} 834 835// Unparsed 836 837// TODO(rbuckton): isUnparsedPrologue 838 839export function isUnparsedPrepend(node: Node): node is UnparsedPrepend { 840 return node.kind === SyntaxKind.UnparsedPrepend; 841} 842 843// TODO(rbuckton): isUnparsedText 844// TODO(rbuckton): isUnparsedInternalText 845// TODO(rbuckton): isUnparsedSyntheticReference 846 847// Top-level nodes 848export function isSourceFile(node: Node): node is SourceFile { 849 return node.kind === SyntaxKind.SourceFile; 850} 851 852export function isBundle(node: Node): node is Bundle { 853 return node.kind === SyntaxKind.Bundle; 854} 855 856export function isUnparsedSource(node: Node): node is UnparsedSource { 857 return node.kind === SyntaxKind.UnparsedSource; 858} 859 860// TODO(rbuckton): isInputFiles 861 862// JSDoc Elements 863 864export function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression { 865 return node.kind === SyntaxKind.JSDocTypeExpression; 866} 867 868export function isJSDocNameReference(node: Node): node is JSDocNameReference { 869 return node.kind === SyntaxKind.JSDocNameReference; 870} 871 872export function isJSDocMemberName(node: Node): node is JSDocMemberName { 873 return node.kind === SyntaxKind.JSDocMemberName; 874} 875 876export function isJSDocLink(node: Node): node is JSDocLink { 877 return node.kind === SyntaxKind.JSDocLink; 878} 879 880export function isJSDocLinkCode(node: Node): node is JSDocLinkCode { 881 return node.kind === SyntaxKind.JSDocLinkCode; 882} 883 884export function isJSDocLinkPlain(node: Node): node is JSDocLinkPlain { 885 return node.kind === SyntaxKind.JSDocLinkPlain; 886} 887 888export function isJSDocAllType(node: Node): node is JSDocAllType { 889 return node.kind === SyntaxKind.JSDocAllType; 890} 891 892export function isJSDocUnknownType(node: Node): node is JSDocUnknownType { 893 return node.kind === SyntaxKind.JSDocUnknownType; 894} 895 896export function isJSDocNullableType(node: Node): node is JSDocNullableType { 897 return node.kind === SyntaxKind.JSDocNullableType; 898} 899 900export function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType { 901 return node.kind === SyntaxKind.JSDocNonNullableType; 902} 903 904export function isJSDocOptionalType(node: Node): node is JSDocOptionalType { 905 return node.kind === SyntaxKind.JSDocOptionalType; 906} 907 908export function isJSDocFunctionType(node: Node): node is JSDocFunctionType { 909 return node.kind === SyntaxKind.JSDocFunctionType; 910} 911 912export function isJSDocVariadicType(node: Node): node is JSDocVariadicType { 913 return node.kind === SyntaxKind.JSDocVariadicType; 914} 915 916export function isJSDocNamepathType(node: Node): node is JSDocNamepathType { 917 return node.kind === SyntaxKind.JSDocNamepathType; 918} 919 920export function isJSDoc(node: Node): node is JSDoc { 921 return node.kind === SyntaxKind.JSDoc; 922} 923 924export function isJSDocTypeLiteral(node: Node): node is JSDocTypeLiteral { 925 return node.kind === SyntaxKind.JSDocTypeLiteral; 926} 927 928export function isJSDocSignature(node: Node): node is JSDocSignature { 929 return node.kind === SyntaxKind.JSDocSignature; 930} 931 932// JSDoc Tags 933 934export function isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag { 935 return node.kind === SyntaxKind.JSDocAugmentsTag; 936} 937 938export function isJSDocAuthorTag(node: Node): node is JSDocAuthorTag { 939 return node.kind === SyntaxKind.JSDocAuthorTag; 940} 941 942export function isJSDocClassTag(node: Node): node is JSDocClassTag { 943 return node.kind === SyntaxKind.JSDocClassTag; 944} 945 946export function isJSDocCallbackTag(node: Node): node is JSDocCallbackTag { 947 return node.kind === SyntaxKind.JSDocCallbackTag; 948} 949 950export function isJSDocPublicTag(node: Node): node is JSDocPublicTag { 951 return node.kind === SyntaxKind.JSDocPublicTag; 952} 953 954export function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag { 955 return node.kind === SyntaxKind.JSDocPrivateTag; 956} 957 958export function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag { 959 return node.kind === SyntaxKind.JSDocProtectedTag; 960} 961 962export function isJSDocReadonlyTag(node: Node): node is JSDocReadonlyTag { 963 return node.kind === SyntaxKind.JSDocReadonlyTag; 964} 965 966export function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag { 967 return node.kind === SyntaxKind.JSDocOverrideTag; 968} 969 970export function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag { 971 return node.kind === SyntaxKind.JSDocDeprecatedTag; 972} 973 974export function isJSDocSeeTag(node: Node): node is JSDocSeeTag { 975 return node.kind === SyntaxKind.JSDocSeeTag; 976} 977 978export function isJSDocEnumTag(node: Node): node is JSDocEnumTag { 979 return node.kind === SyntaxKind.JSDocEnumTag; 980} 981 982export function isJSDocParameterTag(node: Node): node is JSDocParameterTag { 983 return node.kind === SyntaxKind.JSDocParameterTag; 984} 985 986export function isJSDocReturnTag(node: Node): node is JSDocReturnTag { 987 return node.kind === SyntaxKind.JSDocReturnTag; 988} 989 990export function isJSDocThisTag(node: Node): node is JSDocThisTag { 991 return node.kind === SyntaxKind.JSDocThisTag; 992} 993 994export function isJSDocTypeTag(node: Node): node is JSDocTypeTag { 995 return node.kind === SyntaxKind.JSDocTypeTag; 996} 997 998export function isJSDocTemplateTag(node: Node): node is JSDocTemplateTag { 999 return node.kind === SyntaxKind.JSDocTemplateTag; 1000} 1001 1002export function isJSDocTypedefTag(node: Node): node is JSDocTypedefTag { 1003 return node.kind === SyntaxKind.JSDocTypedefTag; 1004} 1005 1006export function isJSDocUnknownTag(node: Node): node is JSDocUnknownTag { 1007 return node.kind === SyntaxKind.JSDocTag; 1008} 1009 1010export function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag { 1011 return node.kind === SyntaxKind.JSDocPropertyTag; 1012} 1013 1014export function isJSDocImplementsTag(node: Node): node is JSDocImplementsTag { 1015 return node.kind === SyntaxKind.JSDocImplementsTag; 1016} 1017 1018// Synthesized list 1019 1020/** @internal */ 1021export function isSyntaxList(n: Node): n is SyntaxList { 1022 return n.kind === SyntaxKind.SyntaxList; 1023} 1024