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