1namespace ts { 2 // branded string type used to store absolute, normalized and canonicalized paths 3 // arbitrary file name can be converted to Path via toPath function 4 export type Path = string & { __pathBrand: any }; 5 6 /* @internal */ 7 export type MatchingKeys<TRecord, TMatch, K extends keyof TRecord = keyof TRecord> = K extends (TRecord[K] extends TMatch ? K : never) ? K : never; 8 9 export interface TextRange { 10 pos: number; 11 end: number; 12 } 13 14 export interface ReadonlyTextRange { 15 readonly pos: number; 16 readonly end: number; 17 } 18 19 // token > SyntaxKind.Identifier => token is a keyword 20 // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync 21 export const enum SyntaxKind { 22 Unknown, 23 EndOfFileToken, 24 SingleLineCommentTrivia, 25 MultiLineCommentTrivia, 26 NewLineTrivia, 27 WhitespaceTrivia, 28 // We detect and preserve #! on the first line 29 ShebangTrivia, 30 // We detect and provide better error recovery when we encounter a git merge marker. This 31 // allows us to edit files with git-conflict markers in them in a much more pleasant manner. 32 ConflictMarkerTrivia, 33 // Literals 34 NumericLiteral, 35 BigIntLiteral, 36 StringLiteral, 37 JsxText, 38 JsxTextAllWhiteSpaces, 39 RegularExpressionLiteral, 40 NoSubstitutionTemplateLiteral, 41 // Pseudo-literals 42 TemplateHead, 43 TemplateMiddle, 44 TemplateTail, 45 // Punctuation 46 OpenBraceToken, 47 CloseBraceToken, 48 OpenParenToken, 49 CloseParenToken, 50 OpenBracketToken, 51 CloseBracketToken, 52 DotToken, 53 DotDotDotToken, 54 SemicolonToken, 55 CommaToken, 56 QuestionDotToken, 57 LessThanToken, 58 LessThanSlashToken, 59 GreaterThanToken, 60 LessThanEqualsToken, 61 GreaterThanEqualsToken, 62 EqualsEqualsToken, 63 ExclamationEqualsToken, 64 EqualsEqualsEqualsToken, 65 ExclamationEqualsEqualsToken, 66 EqualsGreaterThanToken, 67 PlusToken, 68 MinusToken, 69 AsteriskToken, 70 AsteriskAsteriskToken, 71 SlashToken, 72 PercentToken, 73 PlusPlusToken, 74 MinusMinusToken, 75 LessThanLessThanToken, 76 GreaterThanGreaterThanToken, 77 GreaterThanGreaterThanGreaterThanToken, 78 AmpersandToken, 79 BarToken, 80 CaretToken, 81 ExclamationToken, 82 TildeToken, 83 AmpersandAmpersandToken, 84 BarBarToken, 85 QuestionToken, 86 ColonToken, 87 AtToken, 88 QuestionQuestionToken, 89 /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ 90 BacktickToken, 91 // Assignments 92 EqualsToken, 93 PlusEqualsToken, 94 MinusEqualsToken, 95 AsteriskEqualsToken, 96 AsteriskAsteriskEqualsToken, 97 SlashEqualsToken, 98 PercentEqualsToken, 99 LessThanLessThanEqualsToken, 100 GreaterThanGreaterThanEqualsToken, 101 GreaterThanGreaterThanGreaterThanEqualsToken, 102 AmpersandEqualsToken, 103 BarEqualsToken, 104 BarBarEqualsToken, 105 AmpersandAmpersandEqualsToken, 106 QuestionQuestionEqualsToken, 107 CaretEqualsToken, 108 // Identifiers and PrivateIdentifiers 109 Identifier, 110 PrivateIdentifier, 111 // Reserved words 112 BreakKeyword, 113 CaseKeyword, 114 CatchKeyword, 115 ClassKeyword, 116 StructKeyword, 117 ConstKeyword, 118 ContinueKeyword, 119 DebuggerKeyword, 120 DefaultKeyword, 121 DeleteKeyword, 122 DoKeyword, 123 ElseKeyword, 124 EnumKeyword, 125 ExportKeyword, 126 ExtendsKeyword, 127 FalseKeyword, 128 FinallyKeyword, 129 ForKeyword, 130 FunctionKeyword, 131 IfKeyword, 132 ImportKeyword, 133 InKeyword, 134 InstanceOfKeyword, 135 NewKeyword, 136 NullKeyword, 137 ReturnKeyword, 138 SuperKeyword, 139 SwitchKeyword, 140 ThisKeyword, 141 ThrowKeyword, 142 TrueKeyword, 143 TryKeyword, 144 TypeOfKeyword, 145 VarKeyword, 146 VoidKeyword, 147 WhileKeyword, 148 WithKeyword, 149 // Strict mode reserved words 150 ImplementsKeyword, 151 InterfaceKeyword, 152 LetKeyword, 153 PackageKeyword, 154 PrivateKeyword, 155 ProtectedKeyword, 156 PublicKeyword, 157 StaticKeyword, 158 YieldKeyword, 159 // Contextual keywords 160 AbstractKeyword, 161 AsKeyword, 162 AssertsKeyword, 163 AnyKeyword, 164 AsyncKeyword, 165 AwaitKeyword, 166 BooleanKeyword, 167 ConstructorKeyword, 168 DeclareKeyword, 169 GetKeyword, 170 InferKeyword, 171 IntrinsicKeyword, 172 IsKeyword, 173 KeyOfKeyword, 174 ModuleKeyword, 175 NamespaceKeyword, 176 NeverKeyword, 177 ReadonlyKeyword, 178 RequireKeyword, 179 NumberKeyword, 180 ObjectKeyword, 181 SetKeyword, 182 StringKeyword, 183 SymbolKeyword, 184 TypeKeyword, 185 UndefinedKeyword, 186 UniqueKeyword, 187 UnknownKeyword, 188 FromKeyword, 189 GlobalKeyword, 190 BigIntKeyword, 191 OfKeyword, // LastKeyword and LastToken and LastContextualKeyword 192 193 // Parse tree nodes 194 195 // Names 196 QualifiedName, 197 ComputedPropertyName, 198 // Signature elements 199 TypeParameter, 200 Parameter, 201 Decorator, 202 // TypeMember 203 PropertySignature, 204 PropertyDeclaration, 205 MethodSignature, 206 MethodDeclaration, 207 Constructor, 208 GetAccessor, 209 SetAccessor, 210 CallSignature, 211 ConstructSignature, 212 IndexSignature, 213 // Type 214 TypePredicate, 215 TypeReference, 216 FunctionType, 217 ConstructorType, 218 TypeQuery, 219 TypeLiteral, 220 ArrayType, 221 TupleType, 222 OptionalType, 223 RestType, 224 UnionType, 225 IntersectionType, 226 ConditionalType, 227 InferType, 228 ParenthesizedType, 229 ThisType, 230 TypeOperator, 231 IndexedAccessType, 232 MappedType, 233 LiteralType, 234 NamedTupleMember, 235 TemplateLiteralType, 236 TemplateLiteralTypeSpan, 237 ImportType, 238 // Binding patterns 239 ObjectBindingPattern, 240 ArrayBindingPattern, 241 BindingElement, 242 // Expression 243 ArrayLiteralExpression, 244 ObjectLiteralExpression, 245 PropertyAccessExpression, 246 ElementAccessExpression, 247 CallExpression, 248 NewExpression, 249 TaggedTemplateExpression, 250 TypeAssertionExpression, 251 ParenthesizedExpression, 252 FunctionExpression, 253 ArrowFunction, 254 EtsComponentExpression, 255 DeleteExpression, 256 TypeOfExpression, 257 VoidExpression, 258 AwaitExpression, 259 PrefixUnaryExpression, 260 PostfixUnaryExpression, 261 BinaryExpression, 262 ConditionalExpression, 263 TemplateExpression, 264 YieldExpression, 265 SpreadElement, 266 ClassExpression, 267 OmittedExpression, 268 ExpressionWithTypeArguments, 269 AsExpression, 270 NonNullExpression, 271 MetaProperty, 272 SyntheticExpression, 273 274 // Misc 275 TemplateSpan, 276 SemicolonClassElement, 277 // Element 278 Block, 279 EmptyStatement, 280 VariableStatement, 281 ExpressionStatement, 282 IfStatement, 283 DoStatement, 284 WhileStatement, 285 ForStatement, 286 ForInStatement, 287 ForOfStatement, 288 ContinueStatement, 289 BreakStatement, 290 ReturnStatement, 291 WithStatement, 292 SwitchStatement, 293 LabeledStatement, 294 ThrowStatement, 295 TryStatement, 296 DebuggerStatement, 297 VariableDeclaration, 298 VariableDeclarationList, 299 FunctionDeclaration, 300 ClassDeclaration, 301 StructDeclaration, 302 InterfaceDeclaration, 303 TypeAliasDeclaration, 304 EnumDeclaration, 305 ModuleDeclaration, 306 ModuleBlock, 307 CaseBlock, 308 NamespaceExportDeclaration, 309 ImportEqualsDeclaration, 310 ImportDeclaration, 311 ImportClause, 312 NamespaceImport, 313 NamedImports, 314 ImportSpecifier, 315 ExportAssignment, 316 ExportDeclaration, 317 NamedExports, 318 NamespaceExport, 319 ExportSpecifier, 320 MissingDeclaration, 321 322 // Module references 323 ExternalModuleReference, 324 325 // JSX 326 JsxElement, 327 JsxSelfClosingElement, 328 JsxOpeningElement, 329 JsxClosingElement, 330 JsxFragment, 331 JsxOpeningFragment, 332 JsxClosingFragment, 333 JsxAttribute, 334 JsxAttributes, 335 JsxSpreadAttribute, 336 JsxExpression, 337 338 // Clauses 339 CaseClause, 340 DefaultClause, 341 HeritageClause, 342 CatchClause, 343 344 // Property assignments 345 PropertyAssignment, 346 ShorthandPropertyAssignment, 347 SpreadAssignment, 348 349 // Enum 350 EnumMember, 351 // Unparsed 352 UnparsedPrologue, 353 UnparsedPrepend, 354 UnparsedText, 355 UnparsedInternalText, 356 UnparsedSyntheticReference, 357 358 // Top-level nodes 359 SourceFile, 360 Bundle, 361 UnparsedSource, 362 InputFiles, 363 364 // JSDoc nodes 365 JSDocTypeExpression, 366 JSDocNameReference, 367 // The * type 368 JSDocAllType, 369 // The ? type 370 JSDocUnknownType, 371 JSDocNullableType, 372 JSDocNonNullableType, 373 JSDocOptionalType, 374 JSDocFunctionType, 375 JSDocVariadicType, 376 // https://jsdoc.app/about-namepaths.html 377 JSDocNamepathType, 378 JSDocComment, 379 JSDocTypeLiteral, 380 JSDocSignature, 381 JSDocTag, 382 JSDocAugmentsTag, 383 JSDocImplementsTag, 384 JSDocAuthorTag, 385 JSDocDeprecatedTag, 386 JSDocClassTag, 387 JSDocPublicTag, 388 JSDocPrivateTag, 389 JSDocProtectedTag, 390 JSDocReadonlyTag, 391 JSDocCallbackTag, 392 JSDocEnumTag, 393 JSDocParameterTag, 394 JSDocReturnTag, 395 JSDocThisTag, 396 JSDocTypeTag, 397 JSDocTemplateTag, 398 JSDocTypedefTag, 399 JSDocSeeTag, 400 JSDocPropertyTag, 401 402 // Synthesized list 403 SyntaxList, 404 405 // Transformation nodes 406 NotEmittedStatement, 407 PartiallyEmittedExpression, 408 CommaListExpression, 409 MergeDeclarationMarker, 410 EndOfDeclarationMarker, 411 SyntheticReferenceExpression, 412 413 // Enum value count 414 Count, 415 416 // Markers 417 FirstAssignment = EqualsToken, 418 LastAssignment = CaretEqualsToken, 419 FirstCompoundAssignment = PlusEqualsToken, 420 LastCompoundAssignment = CaretEqualsToken, 421 FirstReservedWord = BreakKeyword, 422 LastReservedWord = WithKeyword, 423 FirstKeyword = BreakKeyword, 424 LastKeyword = OfKeyword, 425 FirstFutureReservedWord = ImplementsKeyword, 426 LastFutureReservedWord = YieldKeyword, 427 FirstTypeNode = TypePredicate, 428 LastTypeNode = ImportType, 429 FirstPunctuation = OpenBraceToken, 430 LastPunctuation = CaretEqualsToken, 431 FirstToken = Unknown, 432 LastToken = LastKeyword, 433 FirstTriviaToken = SingleLineCommentTrivia, 434 LastTriviaToken = ConflictMarkerTrivia, 435 FirstLiteralToken = NumericLiteral, 436 LastLiteralToken = NoSubstitutionTemplateLiteral, 437 FirstTemplateToken = NoSubstitutionTemplateLiteral, 438 LastTemplateToken = TemplateTail, 439 FirstBinaryOperator = LessThanToken, 440 LastBinaryOperator = CaretEqualsToken, 441 FirstStatement = VariableStatement, 442 LastStatement = DebuggerStatement, 443 FirstNode = QualifiedName, 444 FirstJSDocNode = JSDocTypeExpression, 445 LastJSDocNode = JSDocPropertyTag, 446 FirstJSDocTagNode = JSDocTag, 447 LastJSDocTagNode = JSDocPropertyTag, 448 /* @internal */ FirstContextualKeyword = AbstractKeyword, 449 /* @internal */ LastContextualKeyword = OfKeyword, 450 } 451 452 export type TriviaSyntaxKind = 453 | SyntaxKind.SingleLineCommentTrivia 454 | SyntaxKind.MultiLineCommentTrivia 455 | SyntaxKind.NewLineTrivia 456 | SyntaxKind.WhitespaceTrivia 457 | SyntaxKind.ShebangTrivia 458 | SyntaxKind.ConflictMarkerTrivia 459 ; 460 461 export type LiteralSyntaxKind = 462 | SyntaxKind.NumericLiteral 463 | SyntaxKind.BigIntLiteral 464 | SyntaxKind.StringLiteral 465 | SyntaxKind.JsxText 466 | SyntaxKind.JsxTextAllWhiteSpaces 467 | SyntaxKind.RegularExpressionLiteral 468 | SyntaxKind.NoSubstitutionTemplateLiteral 469 ; 470 471 export type PseudoLiteralSyntaxKind = 472 | SyntaxKind.TemplateHead 473 | SyntaxKind.TemplateMiddle 474 | SyntaxKind.TemplateTail 475 ; 476 477 export type PunctuationSyntaxKind = 478 | SyntaxKind.OpenBraceToken 479 | SyntaxKind.CloseBraceToken 480 | SyntaxKind.OpenParenToken 481 | SyntaxKind.CloseParenToken 482 | SyntaxKind.OpenBracketToken 483 | SyntaxKind.CloseBracketToken 484 | SyntaxKind.DotToken 485 | SyntaxKind.DotDotDotToken 486 | SyntaxKind.SemicolonToken 487 | SyntaxKind.CommaToken 488 | SyntaxKind.QuestionDotToken 489 | SyntaxKind.LessThanToken 490 | SyntaxKind.LessThanSlashToken 491 | SyntaxKind.GreaterThanToken 492 | SyntaxKind.LessThanEqualsToken 493 | SyntaxKind.GreaterThanEqualsToken 494 | SyntaxKind.EqualsEqualsToken 495 | SyntaxKind.ExclamationEqualsToken 496 | SyntaxKind.EqualsEqualsEqualsToken 497 | SyntaxKind.ExclamationEqualsEqualsToken 498 | SyntaxKind.EqualsGreaterThanToken 499 | SyntaxKind.PlusToken 500 | SyntaxKind.MinusToken 501 | SyntaxKind.AsteriskToken 502 | SyntaxKind.AsteriskAsteriskToken 503 | SyntaxKind.SlashToken 504 | SyntaxKind.PercentToken 505 | SyntaxKind.PlusPlusToken 506 | SyntaxKind.MinusMinusToken 507 | SyntaxKind.LessThanLessThanToken 508 | SyntaxKind.GreaterThanGreaterThanToken 509 | SyntaxKind.GreaterThanGreaterThanGreaterThanToken 510 | SyntaxKind.AmpersandToken 511 | SyntaxKind.BarToken 512 | SyntaxKind.CaretToken 513 | SyntaxKind.ExclamationToken 514 | SyntaxKind.TildeToken 515 | SyntaxKind.AmpersandAmpersandToken 516 | SyntaxKind.BarBarToken 517 | SyntaxKind.QuestionQuestionToken 518 | SyntaxKind.QuestionToken 519 | SyntaxKind.ColonToken 520 | SyntaxKind.AtToken 521 | SyntaxKind.BacktickToken 522 | SyntaxKind.EqualsToken 523 | SyntaxKind.PlusEqualsToken 524 | SyntaxKind.MinusEqualsToken 525 | SyntaxKind.AsteriskEqualsToken 526 | SyntaxKind.AsteriskAsteriskEqualsToken 527 | SyntaxKind.SlashEqualsToken 528 | SyntaxKind.PercentEqualsToken 529 | SyntaxKind.LessThanLessThanEqualsToken 530 | SyntaxKind.GreaterThanGreaterThanEqualsToken 531 | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken 532 | SyntaxKind.AmpersandEqualsToken 533 | SyntaxKind.BarEqualsToken 534 | SyntaxKind.CaretEqualsToken 535 ; 536 537 export type KeywordSyntaxKind = 538 | SyntaxKind.AbstractKeyword 539 | SyntaxKind.AnyKeyword 540 | SyntaxKind.AsKeyword 541 | SyntaxKind.AssertsKeyword 542 | SyntaxKind.AsyncKeyword 543 | SyntaxKind.AwaitKeyword 544 | SyntaxKind.BigIntKeyword 545 | SyntaxKind.BooleanKeyword 546 | SyntaxKind.BreakKeyword 547 | SyntaxKind.CaseKeyword 548 | SyntaxKind.CatchKeyword 549 | SyntaxKind.ClassKeyword 550 | SyntaxKind.StructKeyword 551 | SyntaxKind.ConstKeyword 552 | SyntaxKind.ConstructorKeyword 553 | SyntaxKind.ContinueKeyword 554 | SyntaxKind.DebuggerKeyword 555 | SyntaxKind.DeclareKeyword 556 | SyntaxKind.DefaultKeyword 557 | SyntaxKind.DeleteKeyword 558 | SyntaxKind.DoKeyword 559 | SyntaxKind.ElseKeyword 560 | SyntaxKind.EnumKeyword 561 | SyntaxKind.ExportKeyword 562 | SyntaxKind.ExtendsKeyword 563 | SyntaxKind.FalseKeyword 564 | SyntaxKind.FinallyKeyword 565 | SyntaxKind.ForKeyword 566 | SyntaxKind.FromKeyword 567 | SyntaxKind.FunctionKeyword 568 | SyntaxKind.GetKeyword 569 | SyntaxKind.GlobalKeyword 570 | SyntaxKind.IfKeyword 571 | SyntaxKind.ImplementsKeyword 572 | SyntaxKind.ImportKeyword 573 | SyntaxKind.InferKeyword 574 | SyntaxKind.InKeyword 575 | SyntaxKind.InstanceOfKeyword 576 | SyntaxKind.InterfaceKeyword 577 | SyntaxKind.IntrinsicKeyword 578 | SyntaxKind.IsKeyword 579 | SyntaxKind.KeyOfKeyword 580 | SyntaxKind.LetKeyword 581 | SyntaxKind.ModuleKeyword 582 | SyntaxKind.NamespaceKeyword 583 | SyntaxKind.NeverKeyword 584 | SyntaxKind.NewKeyword 585 | SyntaxKind.NullKeyword 586 | SyntaxKind.NumberKeyword 587 | SyntaxKind.ObjectKeyword 588 | SyntaxKind.OfKeyword 589 | SyntaxKind.PackageKeyword 590 | SyntaxKind.PrivateKeyword 591 | SyntaxKind.ProtectedKeyword 592 | SyntaxKind.PublicKeyword 593 | SyntaxKind.ReadonlyKeyword 594 | SyntaxKind.RequireKeyword 595 | SyntaxKind.ReturnKeyword 596 | SyntaxKind.SetKeyword 597 | SyntaxKind.StaticKeyword 598 | SyntaxKind.StringKeyword 599 | SyntaxKind.SuperKeyword 600 | SyntaxKind.SwitchKeyword 601 | SyntaxKind.SymbolKeyword 602 | SyntaxKind.ThisKeyword 603 | SyntaxKind.ThrowKeyword 604 | SyntaxKind.TrueKeyword 605 | SyntaxKind.TryKeyword 606 | SyntaxKind.TypeKeyword 607 | SyntaxKind.TypeOfKeyword 608 | SyntaxKind.UndefinedKeyword 609 | SyntaxKind.UniqueKeyword 610 | SyntaxKind.UnknownKeyword 611 | SyntaxKind.VarKeyword 612 | SyntaxKind.VoidKeyword 613 | SyntaxKind.WhileKeyword 614 | SyntaxKind.WithKeyword 615 | SyntaxKind.YieldKeyword 616 ; 617 618 export type ModifierSyntaxKind = 619 | SyntaxKind.AbstractKeyword 620 | SyntaxKind.AsyncKeyword 621 | SyntaxKind.ConstKeyword 622 | SyntaxKind.DeclareKeyword 623 | SyntaxKind.DefaultKeyword 624 | SyntaxKind.ExportKeyword 625 | SyntaxKind.PrivateKeyword 626 | SyntaxKind.ProtectedKeyword 627 | SyntaxKind.PublicKeyword 628 | SyntaxKind.ReadonlyKeyword 629 | SyntaxKind.StaticKeyword 630 ; 631 632 export type KeywordTypeSyntaxKind = 633 | SyntaxKind.AnyKeyword 634 | SyntaxKind.BigIntKeyword 635 | SyntaxKind.BooleanKeyword 636 | SyntaxKind.IntrinsicKeyword 637 | SyntaxKind.NeverKeyword 638 | SyntaxKind.NumberKeyword 639 | SyntaxKind.ObjectKeyword 640 | SyntaxKind.StringKeyword 641 | SyntaxKind.SymbolKeyword 642 | SyntaxKind.UndefinedKeyword 643 | SyntaxKind.UnknownKeyword 644 | SyntaxKind.VoidKeyword 645 ; 646 647 /* @internal */ 648 export type TypeNodeSyntaxKind = 649 | KeywordTypeSyntaxKind 650 | SyntaxKind.TypePredicate 651 | SyntaxKind.TypeReference 652 | SyntaxKind.FunctionType 653 | SyntaxKind.ConstructorType 654 | SyntaxKind.TypeQuery 655 | SyntaxKind.TypeLiteral 656 | SyntaxKind.ArrayType 657 | SyntaxKind.TupleType 658 | SyntaxKind.NamedTupleMember 659 | SyntaxKind.OptionalType 660 | SyntaxKind.RestType 661 | SyntaxKind.UnionType 662 | SyntaxKind.IntersectionType 663 | SyntaxKind.ConditionalType 664 | SyntaxKind.InferType 665 | SyntaxKind.ParenthesizedType 666 | SyntaxKind.ThisType 667 | SyntaxKind.TypeOperator 668 | SyntaxKind.IndexedAccessType 669 | SyntaxKind.MappedType 670 | SyntaxKind.LiteralType 671 | SyntaxKind.TemplateLiteralType 672 | SyntaxKind.TemplateLiteralTypeSpan 673 | SyntaxKind.ImportType 674 | SyntaxKind.ExpressionWithTypeArguments 675 | SyntaxKind.JSDocTypeExpression 676 | SyntaxKind.JSDocAllType 677 | SyntaxKind.JSDocUnknownType 678 | SyntaxKind.JSDocNonNullableType 679 | SyntaxKind.JSDocNullableType 680 | SyntaxKind.JSDocOptionalType 681 | SyntaxKind.JSDocFunctionType 682 | SyntaxKind.JSDocVariadicType 683 | SyntaxKind.JSDocNamepathType 684 | SyntaxKind.JSDocSignature 685 | SyntaxKind.JSDocTypeLiteral 686 ; 687 688 export type TokenSyntaxKind = 689 | SyntaxKind.Unknown 690 | SyntaxKind.EndOfFileToken 691 | TriviaSyntaxKind 692 | LiteralSyntaxKind 693 | PseudoLiteralSyntaxKind 694 | PunctuationSyntaxKind 695 | SyntaxKind.Identifier 696 | KeywordSyntaxKind 697 ; 698 699 export type JsxTokenSyntaxKind = 700 | SyntaxKind.LessThanSlashToken 701 | SyntaxKind.EndOfFileToken 702 | SyntaxKind.ConflictMarkerTrivia 703 | SyntaxKind.JsxText 704 | SyntaxKind.JsxTextAllWhiteSpaces 705 | SyntaxKind.OpenBraceToken 706 | SyntaxKind.LessThanToken 707 ; 708 709 export type JSDocSyntaxKind = 710 | SyntaxKind.EndOfFileToken 711 | SyntaxKind.WhitespaceTrivia 712 | SyntaxKind.AtToken 713 | SyntaxKind.NewLineTrivia 714 | SyntaxKind.AsteriskToken 715 | SyntaxKind.OpenBraceToken 716 | SyntaxKind.CloseBraceToken 717 | SyntaxKind.LessThanToken 718 | SyntaxKind.GreaterThanToken 719 | SyntaxKind.OpenBracketToken 720 | SyntaxKind.CloseBracketToken 721 | SyntaxKind.EqualsToken 722 | SyntaxKind.CommaToken 723 | SyntaxKind.DotToken 724 | SyntaxKind.Identifier 725 | SyntaxKind.BacktickToken 726 | SyntaxKind.Unknown 727 | KeywordSyntaxKind 728 ; 729 730 export const enum NodeFlags { 731 None = 0, 732 Let = 1 << 0, // Variable declaration 733 Const = 1 << 1, // Variable declaration 734 NestedNamespace = 1 << 2, // Namespace declaration 735 Synthesized = 1 << 3, // Node was synthesized during transformation 736 Namespace = 1 << 4, // Namespace declaration 737 OptionalChain = 1 << 5, // Chained MemberExpression rooted to a pseudo-OptionalExpression 738 ExportContext = 1 << 6, // Export context (initialized by binding) 739 ContainsThis = 1 << 7, // Interface contains references to "this" 740 HasImplicitReturn = 1 << 8, // If function implicitly returns on one of codepaths (initialized by binding) 741 HasExplicitReturn = 1 << 9, // If function has explicit reachable return on one of codepaths (initialized by binding) 742 GlobalAugmentation = 1 << 10, // Set if module declaration is an augmentation for the global scope 743 HasAsyncFunctions = 1 << 11, // If the file has async functions (initialized by binding) 744 DisallowInContext = 1 << 12, // If node was parsed in a context where 'in-expressions' are not allowed 745 YieldContext = 1 << 13, // If node was parsed in the 'yield' context created when parsing a generator 746 DecoratorContext = 1 << 14, // If node was parsed as part of a decorator 747 AwaitContext = 1 << 15, // If node was parsed in the 'await' context created when parsing an async function 748 ThisNodeHasError = 1 << 16, // If the parser encountered an error when parsing the code that created this node 749 JavaScriptFile = 1 << 17, // If node was parsed in a JavaScript 750 ThisNodeOrAnySubNodesHasError = 1 << 18, // If this node or any of its children had an error 751 HasAggregatedChildData = 1 << 19, // If we've computed data from children and cached it in this node 752 753 // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid 754 // walking the tree if the flags are not set. However, these flags are just a approximation 755 // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. 756 // During editing, if a dynamic import is removed, incremental parsing will *NOT* clear this flag. 757 // This means that the tree will always be traversed during module resolution, or when looking for external module indicators. 758 // However, the removal operation should not occur often and in the case of the 759 // removal, it is likely that users will add the import anyway. 760 // The advantage of this approach is its simplicity. For the case of batch compilation, 761 // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. 762 /* @internal */ PossiblyContainsDynamicImport = 1 << 20, 763 /* @internal */ PossiblyContainsImportMeta = 1 << 21, 764 765 JSDoc = 1 << 22, // If node was parsed inside jsdoc 766 /* @internal */ Ambient = 1 << 23, // If node was inside an ambient context -- a declaration file, or inside something with the `declare` modifier. 767 /* @internal */ InWithStatement = 1 << 24, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`) 768 JsonFile = 1 << 25, // If node was parsed in a Json 769 /* @internal */ TypeCached = 1 << 26, // If a type was cached for node at any point 770 /* @internal */ Deprecated = 1 << 27, // If has '@deprecated' JSDoc tag 771 772 EtsContext = 1 << 30, // If context was parsed as a Struct 773 774 BlockScoped = Let | Const, 775 776 ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn, 777 ReachabilityAndEmitFlags = ReachabilityCheckFlags | HasAsyncFunctions, 778 779 // Parsing context flags 780 ContextFlags = DisallowInContext | YieldContext | DecoratorContext | AwaitContext | JavaScriptFile | InWithStatement | Ambient | EtsContext, 781 782 // Exclude these flags when parsing a Type 783 TypeExcludesFlags = YieldContext | AwaitContext, 784 785 // Represents all flags that are potentially set once and 786 // never cleared on SourceFiles which get re-used in between incremental parses. 787 // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. 788 /* @internal */ PermanentlySetIncrementalFlags = PossiblyContainsDynamicImport | PossiblyContainsImportMeta, 789 } 790 791 export const enum EtsFlags { 792 None = 0, 793 StructContext = 1 << 1, // If context was parsed as a Struct 794 EtsExtendComponentsContext = 1 << 2, // If context was parsed as Ets Extend Components 795 EtsStylesComponentsContext = 1 << 3, // If context was parsed as Ets Styles Components 796 EtsBuildContext = 1 << 4, // If context was parsed as Ets build methods 797 EtsBuilderContext = 1 << 5, // If context was parsed as Ets builder methods or functions 798 EtsStateStylesContext = 1 << 6, // If context was parsed as Ets stateStyles Components 799 EtsComponentsContext = 1 << 7, // If context was parsed as a Ets Components 800 EtsNewExpressionContext = 1 << 8, // If context was parsed ad a new expression 801 } 802 803 export const enum ModifierFlags { 804 None = 0, 805 Export = 1 << 0, // Declarations 806 Ambient = 1 << 1, // Declarations 807 Public = 1 << 2, // Property/Method 808 Private = 1 << 3, // Property/Method 809 Protected = 1 << 4, // Property/Method 810 Static = 1 << 5, // Property/Method 811 Readonly = 1 << 6, // Property/Method 812 Abstract = 1 << 7, // Class/Method/ConstructSignature 813 Async = 1 << 8, // Property/Method/Function 814 Default = 1 << 9, // Function/Class (export default declaration) 815 Const = 1 << 11, // Const enum 816 HasComputedJSDocModifiers = 1 << 12, // Indicates the computed modifier flags include modifiers from JSDoc. 817 818 Deprecated = 1 << 13, // Deprecated tag. 819 HasComputedFlags = 1 << 29, // Modifier flags have been computed 820 821 AccessibilityModifier = Public | Private | Protected, 822 // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. 823 ParameterPropertyModifier = AccessibilityModifier | Readonly, 824 NonPublicAccessibilityModifier = Private | Protected, 825 826 TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const, 827 ExportDefault = Export | Default, 828 All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const | Deprecated 829 } 830 831 export const enum JsxFlags { 832 None = 0, 833 /** An element from a named property of the JSX.IntrinsicElements interface */ 834 IntrinsicNamedElement = 1 << 0, 835 /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ 836 IntrinsicIndexedElement = 1 << 1, 837 838 IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement, 839 } 840 841 /* @internal */ 842 export const enum RelationComparisonResult { 843 Succeeded = 1 << 0, // Should be truthy 844 Failed = 1 << 1, 845 Reported = 1 << 2, 846 847 ReportsUnmeasurable = 1 << 3, 848 ReportsUnreliable = 1 << 4, 849 ReportsMask = ReportsUnmeasurable | ReportsUnreliable 850 } 851 852 /* @internal */ 853 export type NodeId = number; 854 855 export interface Node extends ReadonlyTextRange { 856 readonly kind: SyntaxKind; 857 readonly flags: NodeFlags; 858 /* @internal */ modifierFlagsCache: ModifierFlags; 859 /* @internal */ readonly transformFlags: TransformFlags; // Flags for transforms 860 readonly decorators?: NodeArray<Decorator>; // Array of decorators (in document order) 861 readonly modifiers?: ModifiersArray; // Array of modifiers 862 /* @internal */ id?: NodeId; // Unique id (used to look up NodeLinks) 863 readonly parent: Node; // Parent node (initialized by binding) 864 /* @internal */ original?: Node; // The original node if this is an updated node. 865 symbol: Symbol; // Symbol declared by node (initialized by binding) 866 locals?: SymbolTable; // Locals associated with node (initialized by binding) 867 /* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding) 868 /* @internal */ localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes) 869 /* @internal */ flowNode?: FlowNode; // Associated FlowNode (initialized by binding) 870 /* @internal */ emitNode?: EmitNode; // Associated EmitNode (initialized by transforms) 871 /* @internal */ contextualType?: Type; // Used to temporarily assign a contextual type during overload resolution 872 /* @internal */ inferenceContext?: InferenceContext; // Inference context for contextual type 873 /* @internal */ virtual?: boolean; // Present node is virtual node 874 } 875 876 export interface JSDocContainer { 877 /* @internal */ jsDoc?: JSDoc[]; // JSDoc that directly precedes this node 878 /* @internal */ jsDocCache?: readonly JSDocTag[]; // Cache for getJSDocTags 879 } 880 881 export type HasJSDoc = 882 | ParameterDeclaration 883 | CallSignatureDeclaration 884 | ConstructSignatureDeclaration 885 | MethodSignature 886 | PropertySignature 887 | ArrowFunction 888 | ParenthesizedExpression 889 | SpreadAssignment 890 | ShorthandPropertyAssignment 891 | PropertyAssignment 892 | FunctionExpression 893 | LabeledStatement 894 | ExpressionStatement 895 | VariableStatement 896 | FunctionDeclaration 897 | ConstructorDeclaration 898 | MethodDeclaration 899 | PropertyDeclaration 900 | AccessorDeclaration 901 | ClassLikeDeclaration 902 | InterfaceDeclaration 903 | TypeAliasDeclaration 904 | EnumMember 905 | EnumDeclaration 906 | ModuleDeclaration 907 | ImportEqualsDeclaration 908 | ImportDeclaration 909 | NamespaceExportDeclaration 910 | ExportAssignment 911 | IndexSignatureDeclaration 912 | FunctionTypeNode 913 | ConstructorTypeNode 914 | JSDocFunctionType 915 | ExportDeclaration 916 | NamedTupleMember 917 | EndOfFileToken 918 ; 919 920 export type HasType = 921 | SignatureDeclaration 922 | VariableDeclaration 923 | ParameterDeclaration 924 | PropertySignature 925 | PropertyDeclaration 926 | TypePredicateNode 927 | ParenthesizedTypeNode 928 | TypeOperatorNode 929 | MappedTypeNode 930 | AssertionExpression 931 | TypeAliasDeclaration 932 | JSDocTypeExpression 933 | JSDocNonNullableType 934 | JSDocNullableType 935 | JSDocOptionalType 936 | JSDocVariadicType 937 ; 938 939 export type HasTypeArguments = 940 | CallExpression 941 | NewExpression 942 | TaggedTemplateExpression 943 | JsxOpeningElement 944 | JsxSelfClosingElement; 945 946 export type HasInitializer = 947 | HasExpressionInitializer 948 | ForStatement 949 | ForInStatement 950 | ForOfStatement 951 | JsxAttribute 952 ; 953 954 export type HasExpressionInitializer = 955 | VariableDeclaration 956 | ParameterDeclaration 957 | BindingElement 958 | PropertySignature 959 | PropertyDeclaration 960 | PropertyAssignment 961 | EnumMember 962 ; 963 964 // NOTE: Changing this list requires changes to `canHaveModifiers` in factory/utilities.ts and `updateModifiers` in factory/nodeFactory.ts 965 /* @internal */ 966 export type HasModifiers = 967 | ParameterDeclaration 968 | PropertySignature 969 | PropertyDeclaration 970 | MethodSignature 971 | MethodDeclaration 972 | ConstructorDeclaration 973 | GetAccessorDeclaration 974 | SetAccessorDeclaration 975 | IndexSignatureDeclaration 976 | FunctionExpression 977 | ArrowFunction 978 | ClassExpression 979 | VariableStatement 980 | FunctionDeclaration 981 | ClassDeclaration 982 | StructDeclaration 983 | InterfaceDeclaration 984 | TypeAliasDeclaration 985 | EnumDeclaration 986 | ModuleDeclaration 987 | ImportEqualsDeclaration 988 | ImportDeclaration 989 | ExportAssignment 990 | ExportDeclaration 991 ; 992 993 /* @internal */ 994 export type MutableNodeArray<T extends Node> = NodeArray<T> & T[]; 995 996 export interface NodeArray<T extends Node> extends ReadonlyArray<T>, ReadonlyTextRange { 997 hasTrailingComma?: boolean; 998 /* @internal */ transformFlags: TransformFlags; // Flags for transforms, possibly undefined 999 } 1000 1001 // TODO(rbuckton): Constraint 'TKind' to 'TokenSyntaxKind' 1002 export interface Token<TKind extends SyntaxKind> extends Node { 1003 readonly kind: TKind; 1004 } 1005 1006 export type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer; 1007 1008 // Punctuation 1009 export interface PunctuationToken<TKind extends PunctuationSyntaxKind> extends Token<TKind> { 1010 } 1011 1012 export type DotToken = PunctuationToken<SyntaxKind.DotToken>; 1013 export type DotDotDotToken = PunctuationToken<SyntaxKind.DotDotDotToken>; 1014 export type QuestionToken = PunctuationToken<SyntaxKind.QuestionToken>; 1015 export type ExclamationToken = PunctuationToken<SyntaxKind.ExclamationToken>; 1016 export type ColonToken = PunctuationToken<SyntaxKind.ColonToken>; 1017 export type EqualsToken = PunctuationToken<SyntaxKind.EqualsToken>; 1018 export type AsteriskToken = PunctuationToken<SyntaxKind.AsteriskToken>; 1019 export type EqualsGreaterThanToken = PunctuationToken<SyntaxKind.EqualsGreaterThanToken>; 1020 export type PlusToken = PunctuationToken<SyntaxKind.PlusToken>; 1021 export type MinusToken = PunctuationToken<SyntaxKind.MinusToken>; 1022 export type QuestionDotToken = PunctuationToken<SyntaxKind.QuestionDotToken>; 1023 1024 // Keywords 1025 export interface KeywordToken<TKind extends KeywordSyntaxKind> extends Token<TKind> { 1026 } 1027 1028 export type AssertsKeyword = KeywordToken<SyntaxKind.AssertsKeyword>; 1029 export type AwaitKeyword = KeywordToken<SyntaxKind.AwaitKeyword>; 1030 1031 /** @deprecated Use `AwaitKeyword` instead. */ 1032 export type AwaitKeywordToken = AwaitKeyword; 1033 1034 /** @deprecated Use `AssertsKeyword` instead. */ 1035 export type AssertsToken = AssertsKeyword; 1036 1037 export interface ModifierToken<TKind extends ModifierSyntaxKind> extends KeywordToken<TKind> { 1038 } 1039 1040 export type AbstractKeyword = ModifierToken<SyntaxKind.AbstractKeyword>; 1041 export type AsyncKeyword = ModifierToken<SyntaxKind.AsyncKeyword>; 1042 export type ConstKeyword = ModifierToken<SyntaxKind.ConstKeyword>; 1043 export type DeclareKeyword = ModifierToken<SyntaxKind.DeclareKeyword>; 1044 export type DefaultKeyword = ModifierToken<SyntaxKind.DefaultKeyword>; 1045 export type ExportKeyword = ModifierToken<SyntaxKind.ExportKeyword>; 1046 export type PrivateKeyword = ModifierToken<SyntaxKind.PrivateKeyword>; 1047 export type ProtectedKeyword = ModifierToken<SyntaxKind.ProtectedKeyword>; 1048 export type PublicKeyword = ModifierToken<SyntaxKind.PublicKeyword>; 1049 export type ReadonlyKeyword = ModifierToken<SyntaxKind.ReadonlyKeyword>; 1050 export type StaticKeyword = ModifierToken<SyntaxKind.StaticKeyword>; 1051 1052 /** @deprecated Use `ReadonlyKeyword` instead. */ 1053 export type ReadonlyToken = ReadonlyKeyword; 1054 1055 export type Modifier = 1056 | AbstractKeyword 1057 | AsyncKeyword 1058 | ConstKeyword 1059 | DeclareKeyword 1060 | DefaultKeyword 1061 | ExportKeyword 1062 | PrivateKeyword 1063 | ProtectedKeyword 1064 | PublicKeyword 1065 | ReadonlyKeyword 1066 | StaticKeyword 1067 ; 1068 1069 export type AccessibilityModifier = 1070 | PublicKeyword 1071 | PrivateKeyword 1072 | ProtectedKeyword 1073 ; 1074 1075 export type ParameterPropertyModifier = 1076 | AccessibilityModifier 1077 | ReadonlyKeyword 1078 ; 1079 1080 export type ClassMemberModifier = 1081 | AccessibilityModifier 1082 | ReadonlyKeyword 1083 | StaticKeyword 1084 ; 1085 1086 export type ModifiersArray = NodeArray<Modifier>; 1087 1088 export const enum GeneratedIdentifierFlags { 1089 // Kinds 1090 None = 0, // Not automatically generated. 1091 /*@internal*/ Auto = 1, // Automatically generated identifier. 1092 /*@internal*/ Loop = 2, // Automatically generated identifier with a preference for '_i'. 1093 /*@internal*/ Unique = 3, // Unique name based on the 'text' property. 1094 /*@internal*/ Node = 4, // Unique name based on the node in the 'original' property. 1095 /*@internal*/ KindMask = 7, // Mask to extract the kind of identifier from its flags. 1096 1097 // Flags 1098 ReservedInNestedScopes = 1 << 3, // Reserve the generated name in nested scopes 1099 Optimistic = 1 << 4, // First instance won't use '_#' if there's no conflict 1100 FileLevel = 1 << 5, // Use only the file identifiers list and not generated names to search for conflicts 1101 AllowNameSubstitution = 1 << 6, // Used by `module.ts` to indicate generated nodes which can have substitutions performed upon them (as they were generated by an earlier transform phase) 1102 } 1103 1104 export interface Identifier extends PrimaryExpression, Declaration { 1105 readonly kind: SyntaxKind.Identifier; 1106 /** 1107 * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) 1108 * Text of identifier, but if the identifier begins with two underscores, this will begin with three. 1109 */ 1110 readonly escapedText: __String; 1111 readonly originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later 1112 /*@internal*/ readonly autoGenerateFlags?: GeneratedIdentifierFlags; // Specifies whether to auto-generate the text for an identifier. 1113 /*@internal*/ readonly autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name. 1114 /*@internal*/ generatedImportReference?: ImportSpecifier; // Reference to the generated import specifier this identifier refers to 1115 isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace 1116 /*@internal*/ typeArguments?: NodeArray<TypeNode | TypeParameterDeclaration>; // Only defined on synthesized nodes. Though not syntactically valid, used in emitting diagnostics, quickinfo, and signature help. 1117 /*@internal*/ jsdocDotPos?: number; // Identifier occurs in JSDoc-style generic: Id.<T> 1118 } 1119 1120 // Transient identifier node (marked by id === -1) 1121 export interface TransientIdentifier extends Identifier { 1122 resolvedSymbol: Symbol; 1123 } 1124 1125 /*@internal*/ 1126 export interface GeneratedIdentifier extends Identifier { 1127 autoGenerateFlags: GeneratedIdentifierFlags; 1128 } 1129 1130 export interface QualifiedName extends Node { 1131 readonly kind: SyntaxKind.QualifiedName; 1132 readonly left: EntityName; 1133 readonly right: Identifier; 1134 /*@internal*/ jsdocDotPos?: number; // QualifiedName occurs in JSDoc-style generic: Id1.Id2.<T> 1135 } 1136 1137 export type EntityName = Identifier | QualifiedName; 1138 1139 export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; 1140 1141 export type DeclarationName = 1142 | Identifier 1143 | PrivateIdentifier 1144 | StringLiteralLike 1145 | NumericLiteral 1146 | ComputedPropertyName 1147 | ElementAccessExpression 1148 | BindingPattern 1149 | EntityNameExpression; 1150 1151 export interface Declaration extends Node { 1152 _declarationBrand: any; 1153 } 1154 1155 export interface NamedDeclaration extends Declaration { 1156 readonly name?: DeclarationName; 1157 } 1158 1159 /* @internal */ 1160 export interface DynamicNamedDeclaration extends NamedDeclaration { 1161 readonly name: ComputedPropertyName; 1162 } 1163 1164 /* @internal */ 1165 export interface DynamicNamedBinaryExpression extends BinaryExpression { 1166 readonly left: ElementAccessExpression; 1167 } 1168 1169 /* @internal */ 1170 // A declaration that supports late-binding (used in checker) 1171 export interface LateBoundDeclaration extends DynamicNamedDeclaration { 1172 readonly name: LateBoundName; 1173 } 1174 1175 /* @internal */ 1176 export interface LateBoundBinaryExpressionDeclaration extends DynamicNamedBinaryExpression { 1177 readonly left: LateBoundElementAccessExpression; 1178 } 1179 1180 /* @internal */ 1181 export interface LateBoundElementAccessExpression extends ElementAccessExpression { 1182 readonly argumentExpression: EntityNameExpression; 1183 } 1184 1185 export interface DeclarationStatement extends NamedDeclaration, Statement { 1186 readonly name?: Identifier | StringLiteral | NumericLiteral; 1187 } 1188 1189 export interface ComputedPropertyName extends Node { 1190 readonly kind: SyntaxKind.ComputedPropertyName; 1191 readonly parent: Declaration; 1192 readonly expression: Expression; 1193 } 1194 1195 export interface PrivateIdentifier extends Node { 1196 readonly kind: SyntaxKind.PrivateIdentifier; 1197 // escaping not strictly necessary 1198 // avoids gotchas in transforms and utils 1199 readonly escapedText: __String; 1200 } 1201 1202 1203 /* @internal */ 1204 // A name that supports late-binding (used in checker) 1205 export interface LateBoundName extends ComputedPropertyName { 1206 readonly expression: EntityNameExpression; 1207 } 1208 1209 export interface Decorator extends Node { 1210 readonly kind: SyntaxKind.Decorator; 1211 readonly parent: NamedDeclaration; 1212 readonly expression: LeftHandSideExpression; 1213 } 1214 1215 export interface TypeParameterDeclaration extends NamedDeclaration { 1216 readonly kind: SyntaxKind.TypeParameter; 1217 readonly parent: DeclarationWithTypeParameterChildren | InferTypeNode; 1218 readonly name: Identifier; 1219 /** Note: Consider calling `getEffectiveConstraintOfTypeParameter` */ 1220 readonly constraint?: TypeNode; 1221 readonly default?: TypeNode; 1222 1223 // For error recovery purposes. 1224 expression?: Expression; 1225 } 1226 1227 export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { 1228 readonly kind: SignatureDeclaration["kind"]; 1229 readonly name?: PropertyName; 1230 readonly typeParameters?: NodeArray<TypeParameterDeclaration>; 1231 readonly parameters: NodeArray<ParameterDeclaration>; 1232 readonly type?: TypeNode; 1233 /* @internal */ typeArguments?: NodeArray<TypeNode>; // Used for quick info, replaces typeParameters for instantiated signatures 1234 } 1235 1236 export type SignatureDeclaration = 1237 | CallSignatureDeclaration 1238 | ConstructSignatureDeclaration 1239 | MethodSignature 1240 | IndexSignatureDeclaration 1241 | FunctionTypeNode 1242 | ConstructorTypeNode 1243 | JSDocFunctionType 1244 | FunctionDeclaration 1245 | MethodDeclaration 1246 | ConstructorDeclaration 1247 | AccessorDeclaration 1248 | FunctionExpression 1249 | ArrowFunction; 1250 1251 export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { 1252 readonly kind: SyntaxKind.CallSignature; 1253 } 1254 1255 export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { 1256 readonly kind: SyntaxKind.ConstructSignature; 1257 } 1258 1259 export type BindingName = Identifier | BindingPattern; 1260 1261 export interface VariableDeclaration extends NamedDeclaration { 1262 readonly kind: SyntaxKind.VariableDeclaration; 1263 readonly parent: VariableDeclarationList | CatchClause; 1264 readonly name: BindingName; // Declared variable name 1265 readonly exclamationToken?: ExclamationToken; // Optional definite assignment assertion 1266 readonly type?: TypeNode; // Optional type annotation 1267 readonly initializer?: Expression; // Optional initializer 1268 } 1269 1270 /* @internal */ 1271 export type InitializedVariableDeclaration = VariableDeclaration & { readonly initializer: Expression }; 1272 1273 export interface VariableDeclarationList extends Node { 1274 readonly kind: SyntaxKind.VariableDeclarationList; 1275 readonly parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; 1276 readonly declarations: NodeArray<VariableDeclaration>; 1277 } 1278 1279 export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { 1280 readonly kind: SyntaxKind.Parameter; 1281 readonly parent: SignatureDeclaration; 1282 readonly dotDotDotToken?: DotDotDotToken; // Present on rest parameter 1283 readonly name: BindingName; // Declared parameter name. 1284 readonly questionToken?: QuestionToken; // Present on optional parameter 1285 readonly type?: TypeNode; // Optional type annotation 1286 readonly initializer?: Expression; // Optional initializer 1287 } 1288 1289 export interface BindingElement extends NamedDeclaration { 1290 readonly kind: SyntaxKind.BindingElement; 1291 readonly parent: BindingPattern; 1292 readonly propertyName?: PropertyName; // Binding property name (in object binding pattern) 1293 readonly dotDotDotToken?: DotDotDotToken; // Present on rest element (in object binding pattern) 1294 readonly name: BindingName; // Declared binding element name 1295 readonly initializer?: Expression; // Optional initializer 1296 } 1297 1298 /*@internal*/ 1299 export type BindingElementGrandparent = BindingElement["parent"]["parent"]; 1300 1301 export interface PropertySignature extends TypeElement, JSDocContainer { 1302 readonly kind: SyntaxKind.PropertySignature; 1303 readonly name: PropertyName; // Declared property name 1304 readonly questionToken?: QuestionToken; // Present on optional property 1305 readonly type?: TypeNode; // Optional type annotation 1306 initializer?: Expression; // Present for use with reporting a grammar error 1307 } 1308 1309 export interface PropertyDeclaration extends ClassElement, JSDocContainer { 1310 readonly kind: SyntaxKind.PropertyDeclaration; 1311 readonly parent: ClassLikeDeclaration; 1312 readonly name: PropertyName; 1313 readonly questionToken?: QuestionToken; // Present for use with reporting a grammar error 1314 readonly exclamationToken?: ExclamationToken; 1315 readonly type?: TypeNode; 1316 readonly initializer?: Expression; // Optional initializer 1317 } 1318 1319 /*@internal*/ 1320 export interface PrivateIdentifierPropertyDeclaration extends PropertyDeclaration { 1321 name: PrivateIdentifier; 1322 } 1323 1324 /* @internal */ 1325 export type InitializedPropertyDeclaration = PropertyDeclaration & { readonly initializer: Expression }; 1326 1327 export interface ObjectLiteralElement extends NamedDeclaration { 1328 _objectLiteralBrand: any; 1329 readonly name?: PropertyName; 1330 } 1331 1332 /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ 1333 export type ObjectLiteralElementLike 1334 = PropertyAssignment 1335 | ShorthandPropertyAssignment 1336 | SpreadAssignment 1337 | MethodDeclaration 1338 | AccessorDeclaration 1339 ; 1340 1341 export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { 1342 readonly kind: SyntaxKind.PropertyAssignment; 1343 readonly parent: ObjectLiteralExpression; 1344 readonly name: PropertyName; 1345 readonly questionToken?: QuestionToken; // Present for use with reporting a grammar error 1346 readonly exclamationToken?: ExclamationToken; // Present for use with reporting a grammar error 1347 readonly initializer: Expression; 1348 } 1349 1350 export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { 1351 readonly kind: SyntaxKind.ShorthandPropertyAssignment; 1352 readonly parent: ObjectLiteralExpression; 1353 readonly name: Identifier; 1354 readonly questionToken?: QuestionToken; 1355 readonly exclamationToken?: ExclamationToken; 1356 // used when ObjectLiteralExpression is used in ObjectAssignmentPattern 1357 // it is a grammar error to appear in actual object initializer: 1358 readonly equalsToken?: EqualsToken; 1359 readonly objectAssignmentInitializer?: Expression; 1360 } 1361 1362 export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { 1363 readonly kind: SyntaxKind.SpreadAssignment; 1364 readonly parent: ObjectLiteralExpression; 1365 readonly expression: Expression; 1366 } 1367 1368 export type VariableLikeDeclaration = 1369 | VariableDeclaration 1370 | ParameterDeclaration 1371 | BindingElement 1372 | PropertyDeclaration 1373 | PropertyAssignment 1374 | PropertySignature 1375 | JsxAttribute 1376 | ShorthandPropertyAssignment 1377 | EnumMember 1378 | JSDocPropertyTag 1379 | JSDocParameterTag; 1380 1381 export interface PropertyLikeDeclaration extends NamedDeclaration { 1382 readonly name: PropertyName; 1383 } 1384 1385 export interface ObjectBindingPattern extends Node { 1386 readonly kind: SyntaxKind.ObjectBindingPattern; 1387 readonly parent: VariableDeclaration | ParameterDeclaration | BindingElement; 1388 readonly elements: NodeArray<BindingElement>; 1389 } 1390 1391 export interface ArrayBindingPattern extends Node { 1392 readonly kind: SyntaxKind.ArrayBindingPattern; 1393 readonly parent: VariableDeclaration | ParameterDeclaration | BindingElement; 1394 readonly elements: NodeArray<ArrayBindingElement>; 1395 } 1396 1397 export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; 1398 1399 export type ArrayBindingElement = BindingElement | OmittedExpression; 1400 1401 /** 1402 * Several node kinds share function-like features such as a signature, 1403 * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. 1404 * Examples: 1405 * - FunctionDeclaration 1406 * - MethodDeclaration 1407 * - AccessorDeclaration 1408 */ 1409 export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { 1410 _functionLikeDeclarationBrand: any; 1411 1412 readonly asteriskToken?: AsteriskToken; 1413 readonly questionToken?: QuestionToken; 1414 readonly exclamationToken?: ExclamationToken; 1415 readonly body?: Block | Expression; 1416 /* @internal */ endFlowNode?: FlowNode; 1417 /* @internal */ returnFlowNode?: FlowNode; 1418 } 1419 1420 export type FunctionLikeDeclaration = 1421 | FunctionDeclaration 1422 | MethodDeclaration 1423 | GetAccessorDeclaration 1424 | SetAccessorDeclaration 1425 | ConstructorDeclaration 1426 | FunctionExpression 1427 | ArrowFunction; 1428 /** @deprecated Use SignatureDeclaration */ 1429 export type FunctionLike = SignatureDeclaration; 1430 1431 export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { 1432 readonly kind: SyntaxKind.FunctionDeclaration; 1433 readonly name?: Identifier; 1434 readonly body?: FunctionBody; 1435 } 1436 1437 export interface MethodSignature extends SignatureDeclarationBase, TypeElement { 1438 readonly kind: SyntaxKind.MethodSignature; 1439 readonly parent: ObjectTypeDeclaration; 1440 readonly name: PropertyName; 1441 } 1442 1443 // Note that a MethodDeclaration is considered both a ClassElement and an ObjectLiteralElement. 1444 // Both the grammars for ClassDeclaration and ObjectLiteralExpression allow for MethodDeclarations 1445 // as child elements, and so a MethodDeclaration satisfies both interfaces. This avoids the 1446 // alternative where we would need separate kinds/types for ClassMethodDeclaration and 1447 // ObjectLiteralMethodDeclaration, which would look identical. 1448 // 1449 // Because of this, it may be necessary to determine what sort of MethodDeclaration you have 1450 // at later stages of the compiler pipeline. In that case, you can either check the parent kind 1451 // of the method, or use helpers like isObjectLiteralMethodDeclaration 1452 export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { 1453 readonly kind: SyntaxKind.MethodDeclaration; 1454 readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; 1455 readonly name: PropertyName; 1456 readonly body?: FunctionBody; 1457 /* @internal*/ exclamationToken?: ExclamationToken; // Present for use with reporting a grammar error 1458 } 1459 1460 export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { 1461 readonly kind: SyntaxKind.Constructor; 1462 readonly parent: ClassLikeDeclaration; 1463 readonly body?: FunctionBody; 1464 /* @internal */ typeParameters?: NodeArray<TypeParameterDeclaration>; // Present for use with reporting a grammar error 1465 /* @internal */ type?: TypeNode; // Present for use with reporting a grammar error 1466 } 1467 1468 /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ 1469 export interface SemicolonClassElement extends ClassElement { 1470 readonly kind: SyntaxKind.SemicolonClassElement; 1471 readonly parent: ClassLikeDeclaration; 1472 } 1473 1474 // See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a 1475 // ClassElement and an ObjectLiteralElement. 1476 export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { 1477 readonly kind: SyntaxKind.GetAccessor; 1478 readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; 1479 readonly name: PropertyName; 1480 readonly body?: FunctionBody; 1481 /* @internal */ typeParameters?: NodeArray<TypeParameterDeclaration>; // Present for use with reporting a grammar error 1482 } 1483 1484 // See the comment on MethodDeclaration for the intuition behind SetAccessorDeclaration being a 1485 // ClassElement and an ObjectLiteralElement. 1486 export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { 1487 readonly kind: SyntaxKind.SetAccessor; 1488 readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; 1489 readonly name: PropertyName; 1490 readonly body?: FunctionBody; 1491 /* @internal */ typeParameters?: NodeArray<TypeParameterDeclaration>; // Present for use with reporting a grammar error 1492 /* @internal */ type?: TypeNode; // Present for use with reporting a grammar error 1493 } 1494 1495 export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; 1496 1497 export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { 1498 readonly kind: SyntaxKind.IndexSignature; 1499 readonly parent: ObjectTypeDeclaration; 1500 readonly type: TypeNode; 1501 } 1502 1503 export interface TypeNode extends Node { 1504 _typeNodeBrand: any; 1505 } 1506 1507 /* @internal */ 1508 export interface TypeNode extends Node { 1509 readonly kind: TypeNodeSyntaxKind; 1510 } 1511 1512 export interface KeywordTypeNode<TKind extends KeywordTypeSyntaxKind = KeywordTypeSyntaxKind> extends KeywordToken<TKind>, TypeNode { 1513 readonly kind: TKind; 1514 } 1515 1516 export interface ImportTypeNode extends NodeWithTypeArguments { 1517 readonly kind: SyntaxKind.ImportType; 1518 readonly isTypeOf: boolean; 1519 readonly argument: TypeNode; 1520 readonly qualifier?: EntityName; 1521 } 1522 1523 /* @internal */ 1524 export type LiteralImportTypeNode = ImportTypeNode & { readonly argument: LiteralTypeNode & { readonly literal: StringLiteral } }; 1525 1526 export interface ThisTypeNode extends TypeNode { 1527 readonly kind: SyntaxKind.ThisType; 1528 } 1529 1530 export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; 1531 1532 export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { 1533 readonly kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; 1534 readonly type: TypeNode; 1535 } 1536 1537 export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { 1538 readonly kind: SyntaxKind.FunctionType; 1539 } 1540 1541 export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { 1542 readonly kind: SyntaxKind.ConstructorType; 1543 } 1544 1545 export interface NodeWithTypeArguments extends TypeNode { 1546 readonly typeArguments?: NodeArray<TypeNode>; 1547 } 1548 1549 export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; 1550 1551 export interface TypeReferenceNode extends NodeWithTypeArguments { 1552 readonly kind: SyntaxKind.TypeReference; 1553 readonly typeName: EntityName; 1554 } 1555 1556 export interface TypePredicateNode extends TypeNode { 1557 readonly kind: SyntaxKind.TypePredicate; 1558 readonly parent: SignatureDeclaration | JSDocTypeExpression; 1559 readonly assertsModifier?: AssertsToken; 1560 readonly parameterName: Identifier | ThisTypeNode; 1561 readonly type?: TypeNode; 1562 } 1563 1564 export interface TypeQueryNode extends TypeNode { 1565 readonly kind: SyntaxKind.TypeQuery; 1566 readonly exprName: EntityName; 1567 } 1568 1569 // A TypeLiteral is the declaration node for an anonymous symbol. 1570 export interface TypeLiteralNode extends TypeNode, Declaration { 1571 readonly kind: SyntaxKind.TypeLiteral; 1572 readonly members: NodeArray<TypeElement>; 1573 } 1574 1575 export interface ArrayTypeNode extends TypeNode { 1576 readonly kind: SyntaxKind.ArrayType; 1577 readonly elementType: TypeNode; 1578 } 1579 1580 export interface TupleTypeNode extends TypeNode { 1581 readonly kind: SyntaxKind.TupleType; 1582 readonly elements: NodeArray<TypeNode | NamedTupleMember>; 1583 } 1584 1585 export interface NamedTupleMember extends TypeNode, JSDocContainer, Declaration { 1586 readonly kind: SyntaxKind.NamedTupleMember; 1587 readonly dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>; 1588 readonly name: Identifier; 1589 readonly questionToken?: Token<SyntaxKind.QuestionToken>; 1590 readonly type: TypeNode; 1591 } 1592 1593 export interface OptionalTypeNode extends TypeNode { 1594 readonly kind: SyntaxKind.OptionalType; 1595 readonly type: TypeNode; 1596 } 1597 1598 export interface RestTypeNode extends TypeNode { 1599 readonly kind: SyntaxKind.RestType; 1600 readonly type: TypeNode; 1601 } 1602 1603 export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; 1604 1605 export interface UnionTypeNode extends TypeNode { 1606 readonly kind: SyntaxKind.UnionType; 1607 readonly types: NodeArray<TypeNode>; 1608 } 1609 1610 export interface IntersectionTypeNode extends TypeNode { 1611 readonly kind: SyntaxKind.IntersectionType; 1612 readonly types: NodeArray<TypeNode>; 1613 } 1614 1615 export interface ConditionalTypeNode extends TypeNode { 1616 readonly kind: SyntaxKind.ConditionalType; 1617 readonly checkType: TypeNode; 1618 readonly extendsType: TypeNode; 1619 readonly trueType: TypeNode; 1620 readonly falseType: TypeNode; 1621 } 1622 1623 export interface InferTypeNode extends TypeNode { 1624 readonly kind: SyntaxKind.InferType; 1625 readonly typeParameter: TypeParameterDeclaration; 1626 } 1627 1628 export interface ParenthesizedTypeNode extends TypeNode { 1629 readonly kind: SyntaxKind.ParenthesizedType; 1630 readonly type: TypeNode; 1631 } 1632 1633 export interface TypeOperatorNode extends TypeNode { 1634 readonly kind: SyntaxKind.TypeOperator; 1635 readonly operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; 1636 readonly type: TypeNode; 1637 } 1638 1639 /* @internal */ 1640 export interface UniqueTypeOperatorNode extends TypeOperatorNode { 1641 readonly operator: SyntaxKind.UniqueKeyword; 1642 } 1643 1644 export interface IndexedAccessTypeNode extends TypeNode { 1645 readonly kind: SyntaxKind.IndexedAccessType; 1646 readonly objectType: TypeNode; 1647 readonly indexType: TypeNode; 1648 } 1649 1650 export interface MappedTypeNode extends TypeNode, Declaration { 1651 readonly kind: SyntaxKind.MappedType; 1652 readonly readonlyToken?: ReadonlyToken | PlusToken | MinusToken; 1653 readonly typeParameter: TypeParameterDeclaration; 1654 readonly nameType?: TypeNode; 1655 readonly questionToken?: QuestionToken | PlusToken | MinusToken; 1656 readonly type?: TypeNode; 1657 } 1658 1659 export interface LiteralTypeNode extends TypeNode { 1660 readonly kind: SyntaxKind.LiteralType; 1661 readonly literal: NullLiteral | BooleanLiteral | LiteralExpression | PrefixUnaryExpression; 1662 } 1663 1664 export interface StringLiteral extends LiteralExpression, Declaration { 1665 readonly kind: SyntaxKind.StringLiteral; 1666 /* @internal */ readonly textSourceNode?: Identifier | StringLiteralLike | NumericLiteral; // Allows a StringLiteral to get its text from another node (used by transforms). 1667 /** Note: this is only set when synthesizing a node, not during parsing. */ 1668 /* @internal */ readonly singleQuote?: boolean; 1669 } 1670 1671 export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; 1672 export type PropertyNameLiteral = Identifier | StringLiteralLike | NumericLiteral; 1673 1674 export interface TemplateLiteralTypeNode extends TypeNode { 1675 kind: SyntaxKind.TemplateLiteralType, 1676 readonly head: TemplateHead; 1677 readonly templateSpans: NodeArray<TemplateLiteralTypeSpan>; 1678 } 1679 1680 export interface TemplateLiteralTypeSpan extends TypeNode { 1681 readonly kind: SyntaxKind.TemplateLiteralTypeSpan, 1682 readonly parent: TemplateLiteralTypeNode; 1683 readonly type: TypeNode; 1684 readonly literal: TemplateMiddle | TemplateTail; 1685 } 1686 1687 // Note: 'brands' in our syntax nodes serve to give us a small amount of nominal typing. 1688 // Consider 'Expression'. Without the brand, 'Expression' is actually no different 1689 // (structurally) than 'Node'. Because of this you can pass any Node to a function that 1690 // takes an Expression without any error. By using the 'brands' we ensure that the type 1691 // checker actually thinks you have something of the right type. Note: the brands are 1692 // never actually given values. At runtime they have zero cost. 1693 1694 export interface Expression extends Node { 1695 _expressionBrand: any; 1696 } 1697 1698 export interface OmittedExpression extends Expression { 1699 readonly kind: SyntaxKind.OmittedExpression; 1700 } 1701 1702 // Represents an expression that is elided as part of a transformation to emit comments on a 1703 // not-emitted node. The 'expression' property of a PartiallyEmittedExpression should be emitted. 1704 export interface PartiallyEmittedExpression extends LeftHandSideExpression { 1705 readonly kind: SyntaxKind.PartiallyEmittedExpression; 1706 readonly expression: Expression; 1707 } 1708 1709 export interface UnaryExpression extends Expression { 1710 _unaryExpressionBrand: any; 1711 } 1712 1713 /** Deprecated, please use UpdateExpression */ 1714 export type IncrementExpression = UpdateExpression; 1715 export interface UpdateExpression extends UnaryExpression { 1716 _updateExpressionBrand: any; 1717 } 1718 1719 // see: https://tc39.github.io/ecma262/#prod-UpdateExpression 1720 // see: https://tc39.github.io/ecma262/#prod-UnaryExpression 1721 export type PrefixUnaryOperator 1722 = SyntaxKind.PlusPlusToken 1723 | SyntaxKind.MinusMinusToken 1724 | SyntaxKind.PlusToken 1725 | SyntaxKind.MinusToken 1726 | SyntaxKind.TildeToken 1727 | SyntaxKind.ExclamationToken; 1728 1729 export interface PrefixUnaryExpression extends UpdateExpression { 1730 readonly kind: SyntaxKind.PrefixUnaryExpression; 1731 readonly operator: PrefixUnaryOperator; 1732 readonly operand: UnaryExpression; 1733 } 1734 1735 // see: https://tc39.github.io/ecma262/#prod-UpdateExpression 1736 export type PostfixUnaryOperator 1737 = SyntaxKind.PlusPlusToken 1738 | SyntaxKind.MinusMinusToken 1739 ; 1740 1741 export interface PostfixUnaryExpression extends UpdateExpression { 1742 readonly kind: SyntaxKind.PostfixUnaryExpression; 1743 readonly operand: LeftHandSideExpression; 1744 readonly operator: PostfixUnaryOperator; 1745 } 1746 1747 export interface LeftHandSideExpression extends UpdateExpression { 1748 _leftHandSideExpressionBrand: any; 1749 } 1750 1751 export interface MemberExpression extends LeftHandSideExpression { 1752 _memberExpressionBrand: any; 1753 } 1754 1755 export interface PrimaryExpression extends MemberExpression { 1756 _primaryExpressionBrand: any; 1757 } 1758 1759 export interface NullLiteral extends PrimaryExpression { 1760 readonly kind: SyntaxKind.NullKeyword; 1761 } 1762 1763 export interface TrueLiteral extends PrimaryExpression { 1764 readonly kind: SyntaxKind.TrueKeyword; 1765 } 1766 1767 export interface FalseLiteral extends PrimaryExpression { 1768 readonly kind: SyntaxKind.FalseKeyword; 1769 } 1770 1771 export type BooleanLiteral = TrueLiteral | FalseLiteral; 1772 1773 export interface ThisExpression extends PrimaryExpression { 1774 readonly kind: SyntaxKind.ThisKeyword; 1775 } 1776 1777 export interface SuperExpression extends PrimaryExpression { 1778 readonly kind: SyntaxKind.SuperKeyword; 1779 } 1780 1781 export interface ImportExpression extends PrimaryExpression { 1782 readonly kind: SyntaxKind.ImportKeyword; 1783 } 1784 1785 export interface DeleteExpression extends UnaryExpression { 1786 readonly kind: SyntaxKind.DeleteExpression; 1787 readonly expression: UnaryExpression; 1788 } 1789 1790 export interface TypeOfExpression extends UnaryExpression { 1791 readonly kind: SyntaxKind.TypeOfExpression; 1792 readonly expression: UnaryExpression; 1793 } 1794 1795 export interface VoidExpression extends UnaryExpression { 1796 readonly kind: SyntaxKind.VoidExpression; 1797 readonly expression: UnaryExpression; 1798 } 1799 1800 export interface AwaitExpression extends UnaryExpression { 1801 readonly kind: SyntaxKind.AwaitExpression; 1802 readonly expression: UnaryExpression; 1803 } 1804 1805 export interface YieldExpression extends Expression { 1806 readonly kind: SyntaxKind.YieldExpression; 1807 readonly asteriskToken?: AsteriskToken; 1808 readonly expression?: Expression; 1809 } 1810 1811 export interface SyntheticExpression extends Expression { 1812 readonly kind: SyntaxKind.SyntheticExpression; 1813 readonly isSpread: boolean; 1814 readonly type: Type; 1815 readonly tupleNameSource?: ParameterDeclaration | NamedTupleMember; 1816 } 1817 1818 // see: https://tc39.github.io/ecma262/#prod-ExponentiationExpression 1819 export type ExponentiationOperator = 1820 | SyntaxKind.AsteriskAsteriskToken 1821 ; 1822 1823 // see: https://tc39.github.io/ecma262/#prod-MultiplicativeOperator 1824 export type MultiplicativeOperator = 1825 | SyntaxKind.AsteriskToken 1826 | SyntaxKind.SlashToken 1827 | SyntaxKind.PercentToken 1828 ; 1829 1830 // see: https://tc39.github.io/ecma262/#prod-MultiplicativeExpression 1831 export type MultiplicativeOperatorOrHigher = 1832 | ExponentiationOperator 1833 | MultiplicativeOperator 1834 ; 1835 1836 // see: https://tc39.github.io/ecma262/#prod-AdditiveExpression 1837 export type AdditiveOperator = 1838 | SyntaxKind.PlusToken 1839 | SyntaxKind.MinusToken 1840 ; 1841 1842 // see: https://tc39.github.io/ecma262/#prod-AdditiveExpression 1843 export type AdditiveOperatorOrHigher = 1844 | MultiplicativeOperatorOrHigher 1845 | AdditiveOperator 1846 ; 1847 1848 // see: https://tc39.github.io/ecma262/#prod-ShiftExpression 1849 export type ShiftOperator = 1850 | SyntaxKind.LessThanLessThanToken 1851 | SyntaxKind.GreaterThanGreaterThanToken 1852 | SyntaxKind.GreaterThanGreaterThanGreaterThanToken 1853 ; 1854 1855 // see: https://tc39.github.io/ecma262/#prod-ShiftExpression 1856 export type ShiftOperatorOrHigher = 1857 | AdditiveOperatorOrHigher 1858 | ShiftOperator 1859 ; 1860 1861 // see: https://tc39.github.io/ecma262/#prod-RelationalExpression 1862 export type RelationalOperator = 1863 | SyntaxKind.LessThanToken 1864 | SyntaxKind.LessThanEqualsToken 1865 | SyntaxKind.GreaterThanToken 1866 | SyntaxKind.GreaterThanEqualsToken 1867 | SyntaxKind.InstanceOfKeyword 1868 | SyntaxKind.InKeyword 1869 ; 1870 1871 // see: https://tc39.github.io/ecma262/#prod-RelationalExpression 1872 export type RelationalOperatorOrHigher = 1873 | ShiftOperatorOrHigher 1874 | RelationalOperator 1875 ; 1876 1877 // see: https://tc39.github.io/ecma262/#prod-EqualityExpression 1878 export type EqualityOperator = 1879 | SyntaxKind.EqualsEqualsToken 1880 | SyntaxKind.EqualsEqualsEqualsToken 1881 | SyntaxKind.ExclamationEqualsEqualsToken 1882 | SyntaxKind.ExclamationEqualsToken 1883 ; 1884 1885 // see: https://tc39.github.io/ecma262/#prod-EqualityExpression 1886 export type EqualityOperatorOrHigher = 1887 | RelationalOperatorOrHigher 1888 | EqualityOperator; 1889 1890 // see: https://tc39.github.io/ecma262/#prod-BitwiseANDExpression 1891 // see: https://tc39.github.io/ecma262/#prod-BitwiseXORExpression 1892 // see: https://tc39.github.io/ecma262/#prod-BitwiseORExpression 1893 export type BitwiseOperator = 1894 | SyntaxKind.AmpersandToken 1895 | SyntaxKind.BarToken 1896 | SyntaxKind.CaretToken 1897 ; 1898 1899 // see: https://tc39.github.io/ecma262/#prod-BitwiseANDExpression 1900 // see: https://tc39.github.io/ecma262/#prod-BitwiseXORExpression 1901 // see: https://tc39.github.io/ecma262/#prod-BitwiseORExpression 1902 export type BitwiseOperatorOrHigher = 1903 | EqualityOperatorOrHigher 1904 | BitwiseOperator 1905 ; 1906 1907 // see: https://tc39.github.io/ecma262/#prod-LogicalANDExpression 1908 // see: https://tc39.github.io/ecma262/#prod-LogicalORExpression 1909 export type LogicalOperator = 1910 | SyntaxKind.AmpersandAmpersandToken 1911 | SyntaxKind.BarBarToken 1912 ; 1913 1914 // see: https://tc39.github.io/ecma262/#prod-LogicalANDExpression 1915 // see: https://tc39.github.io/ecma262/#prod-LogicalORExpression 1916 export type LogicalOperatorOrHigher = 1917 | BitwiseOperatorOrHigher 1918 | LogicalOperator 1919 ; 1920 1921 // see: https://tc39.github.io/ecma262/#prod-AssignmentOperator 1922 export type CompoundAssignmentOperator = 1923 | SyntaxKind.PlusEqualsToken 1924 | SyntaxKind.MinusEqualsToken 1925 | SyntaxKind.AsteriskAsteriskEqualsToken 1926 | SyntaxKind.AsteriskEqualsToken 1927 | SyntaxKind.SlashEqualsToken 1928 | SyntaxKind.PercentEqualsToken 1929 | SyntaxKind.AmpersandEqualsToken 1930 | SyntaxKind.BarEqualsToken 1931 | SyntaxKind.CaretEqualsToken 1932 | SyntaxKind.LessThanLessThanEqualsToken 1933 | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken 1934 | SyntaxKind.GreaterThanGreaterThanEqualsToken 1935 | SyntaxKind.BarBarEqualsToken 1936 | SyntaxKind.AmpersandAmpersandEqualsToken 1937 | SyntaxKind.QuestionQuestionEqualsToken 1938 ; 1939 1940 // see: https://tc39.github.io/ecma262/#prod-AssignmentExpression 1941 export type AssignmentOperator = 1942 | SyntaxKind.EqualsToken 1943 | CompoundAssignmentOperator 1944 ; 1945 1946 // see: https://tc39.github.io/ecma262/#prod-AssignmentExpression 1947 export type AssignmentOperatorOrHigher = 1948 | SyntaxKind.QuestionQuestionToken 1949 | LogicalOperatorOrHigher 1950 | AssignmentOperator 1951 ; 1952 1953 // see: https://tc39.github.io/ecma262/#prod-Expression 1954 export type BinaryOperator = 1955 | AssignmentOperatorOrHigher 1956 | SyntaxKind.CommaToken 1957 ; 1958 1959 export type LogicalOrCoalescingAssignmentOperator 1960 = SyntaxKind.AmpersandAmpersandEqualsToken 1961 | SyntaxKind.BarBarEqualsToken 1962 | SyntaxKind.QuestionQuestionEqualsToken 1963 ; 1964 1965 export type BinaryOperatorToken = Token<BinaryOperator>; 1966 1967 export interface BinaryExpression extends Expression, Declaration { 1968 readonly kind: SyntaxKind.BinaryExpression; 1969 readonly left: Expression; 1970 readonly operatorToken: BinaryOperatorToken; 1971 readonly right: Expression; 1972 } 1973 1974 export type AssignmentOperatorToken = Token<AssignmentOperator>; 1975 1976 export interface AssignmentExpression<TOperator extends AssignmentOperatorToken> extends BinaryExpression { 1977 readonly left: LeftHandSideExpression; 1978 readonly operatorToken: TOperator; 1979 } 1980 1981 export interface ObjectDestructuringAssignment extends AssignmentExpression<EqualsToken> { 1982 readonly left: ObjectLiteralExpression; 1983 } 1984 1985 export interface ArrayDestructuringAssignment extends AssignmentExpression<EqualsToken> { 1986 readonly left: ArrayLiteralExpression; 1987 } 1988 1989 export type DestructuringAssignment = 1990 | ObjectDestructuringAssignment 1991 | ArrayDestructuringAssignment 1992 ; 1993 1994 export type BindingOrAssignmentElement = 1995 | VariableDeclaration 1996 | ParameterDeclaration 1997 | ObjectBindingOrAssignmentElement 1998 | ArrayBindingOrAssignmentElement 1999 ; 2000 2001 export type ObjectBindingOrAssignmentElement = 2002 | BindingElement 2003 | PropertyAssignment // AssignmentProperty 2004 | ShorthandPropertyAssignment // AssignmentProperty 2005 | SpreadAssignment // AssignmentRestProperty 2006 ; 2007 2008 export type ArrayBindingOrAssignmentElement = 2009 | BindingElement 2010 | OmittedExpression // Elision 2011 | SpreadElement // AssignmentRestElement 2012 | ArrayLiteralExpression // ArrayAssignmentPattern 2013 | ObjectLiteralExpression // ObjectAssignmentPattern 2014 | AssignmentExpression<EqualsToken> // AssignmentElement 2015 | Identifier // DestructuringAssignmentTarget 2016 | PropertyAccessExpression // DestructuringAssignmentTarget 2017 | ElementAccessExpression // DestructuringAssignmentTarget 2018 ; 2019 2020 export type BindingOrAssignmentElementRestIndicator = 2021 | DotDotDotToken // from BindingElement 2022 | SpreadElement // AssignmentRestElement 2023 | SpreadAssignment // AssignmentRestProperty 2024 ; 2025 2026 export type BindingOrAssignmentElementTarget = 2027 | BindingOrAssignmentPattern 2028 | Identifier 2029 | PropertyAccessExpression 2030 | ElementAccessExpression 2031 | OmittedExpression; 2032 2033 export type ObjectBindingOrAssignmentPattern = 2034 | ObjectBindingPattern 2035 | ObjectLiteralExpression // ObjectAssignmentPattern 2036 ; 2037 2038 export type ArrayBindingOrAssignmentPattern = 2039 | ArrayBindingPattern 2040 | ArrayLiteralExpression // ArrayAssignmentPattern 2041 ; 2042 2043 export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; 2044 2045 export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; 2046 2047 export interface ConditionalExpression extends Expression { 2048 readonly kind: SyntaxKind.ConditionalExpression; 2049 readonly condition: Expression; 2050 readonly questionToken: QuestionToken; 2051 readonly whenTrue: Expression; 2052 readonly colonToken: ColonToken; 2053 readonly whenFalse: Expression; 2054 } 2055 2056 export type FunctionBody = Block; 2057 export type ConciseBody = FunctionBody | Expression; 2058 2059 export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { 2060 readonly kind: SyntaxKind.FunctionExpression; 2061 readonly name?: Identifier; 2062 readonly body: FunctionBody; // Required, whereas the member inherited from FunctionDeclaration is optional 2063 } 2064 2065 export interface EtsComponentExpression extends PrimaryExpression, Declaration { 2066 readonly kind: SyntaxKind.EtsComponentExpression; 2067 readonly expression: LeftHandSideExpression; 2068 readonly typeArguments?: NodeArray<TypeNode>; 2069 readonly arguments: NodeArray<Expression>; 2070 readonly body?: Block; 2071 } 2072 2073 export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { 2074 readonly kind: SyntaxKind.ArrowFunction; 2075 readonly equalsGreaterThanToken: EqualsGreaterThanToken; 2076 readonly body: ConciseBody; 2077 readonly name: never; 2078 } 2079 2080 // The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral, 2081 // or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters. 2082 // For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1". 2083 export interface LiteralLikeNode extends Node { 2084 text: string; 2085 isUnterminated?: boolean; 2086 hasExtendedUnicodeEscape?: boolean; 2087 } 2088 2089 export interface TemplateLiteralLikeNode extends LiteralLikeNode { 2090 rawText?: string; 2091 /* @internal */ 2092 templateFlags?: TokenFlags; 2093 } 2094 2095 // The text property of a LiteralExpression stores the interpreted value of the literal in text form. For a StringLiteral, 2096 // or any literal of a template, this means quotes have been removed and escapes have been converted to actual characters. 2097 // For a NumericLiteral, the stored value is the toString() representation of the number. For example 1, 1.00, and 1e0 are all stored as just "1". 2098 export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { 2099 _literalExpressionBrand: any; 2100 } 2101 2102 export interface RegularExpressionLiteral extends LiteralExpression { 2103 readonly kind: SyntaxKind.RegularExpressionLiteral; 2104 } 2105 2106 export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { 2107 readonly kind: SyntaxKind.NoSubstitutionTemplateLiteral; 2108 /* @internal */ 2109 templateFlags?: TokenFlags; 2110 } 2111 2112 export const enum TokenFlags { 2113 None = 0, 2114 /* @internal */ 2115 PrecedingLineBreak = 1 << 0, 2116 /* @internal */ 2117 PrecedingJSDocComment = 1 << 1, 2118 /* @internal */ 2119 Unterminated = 1 << 2, 2120 /* @internal */ 2121 ExtendedUnicodeEscape = 1 << 3, 2122 Scientific = 1 << 4, // e.g. `10e2` 2123 Octal = 1 << 5, // e.g. `0777` 2124 HexSpecifier = 1 << 6, // e.g. `0x00000000` 2125 BinarySpecifier = 1 << 7, // e.g. `0b0110010000000000` 2126 OctalSpecifier = 1 << 8, // e.g. `0o777` 2127 /* @internal */ 2128 ContainsSeparator = 1 << 9, // e.g. `0b1100_0101` 2129 /* @internal */ 2130 UnicodeEscape = 1 << 10, 2131 /* @internal */ 2132 ContainsInvalidEscape = 1 << 11, // e.g. `\uhello` 2133 /* @internal */ 2134 BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier, 2135 /* @internal */ 2136 NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator, 2137 /* @internal */ 2138 TemplateLiteralLikeFlags = ContainsInvalidEscape, 2139 } 2140 2141 export interface NumericLiteral extends LiteralExpression, Declaration { 2142 readonly kind: SyntaxKind.NumericLiteral; 2143 /* @internal */ 2144 readonly numericLiteralFlags: TokenFlags; 2145 } 2146 2147 export interface BigIntLiteral extends LiteralExpression { 2148 readonly kind: SyntaxKind.BigIntLiteral; 2149 } 2150 2151 export type LiteralToken = 2152 | NumericLiteral 2153 | BigIntLiteral 2154 | StringLiteral 2155 | JsxText 2156 | RegularExpressionLiteral 2157 | NoSubstitutionTemplateLiteral 2158 ; 2159 2160 export interface TemplateHead extends TemplateLiteralLikeNode { 2161 readonly kind: SyntaxKind.TemplateHead; 2162 readonly parent: TemplateExpression | TemplateLiteralTypeNode; 2163 /* @internal */ 2164 templateFlags?: TokenFlags; 2165 } 2166 2167 export interface TemplateMiddle extends TemplateLiteralLikeNode { 2168 readonly kind: SyntaxKind.TemplateMiddle; 2169 readonly parent: TemplateSpan | TemplateLiteralTypeSpan; 2170 /* @internal */ 2171 templateFlags?: TokenFlags; 2172 } 2173 2174 export interface TemplateTail extends TemplateLiteralLikeNode { 2175 readonly kind: SyntaxKind.TemplateTail; 2176 readonly parent: TemplateSpan | TemplateLiteralTypeSpan; 2177 /* @internal */ 2178 templateFlags?: TokenFlags; 2179 } 2180 2181 export type PseudoLiteralToken = 2182 | TemplateHead 2183 | TemplateMiddle 2184 | TemplateTail 2185 ; 2186 2187 export type TemplateLiteralToken = 2188 | NoSubstitutionTemplateLiteral 2189 | PseudoLiteralToken 2190 ; 2191 2192 export interface TemplateExpression extends PrimaryExpression { 2193 readonly kind: SyntaxKind.TemplateExpression; 2194 readonly head: TemplateHead; 2195 readonly templateSpans: NodeArray<TemplateSpan>; 2196 } 2197 2198 export type TemplateLiteral = 2199 | TemplateExpression 2200 | NoSubstitutionTemplateLiteral 2201 ; 2202 2203 // Each of these corresponds to a substitution expression and a template literal, in that order. 2204 // The template literal must have kind TemplateMiddleLiteral or TemplateTailLiteral. 2205 export interface TemplateSpan extends Node { 2206 readonly kind: SyntaxKind.TemplateSpan; 2207 readonly parent: TemplateExpression; 2208 readonly expression: Expression; 2209 readonly literal: TemplateMiddle | TemplateTail; 2210 } 2211 2212 export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { 2213 readonly kind: SyntaxKind.ParenthesizedExpression; 2214 readonly expression: Expression; 2215 } 2216 2217 export interface ArrayLiteralExpression extends PrimaryExpression { 2218 readonly kind: SyntaxKind.ArrayLiteralExpression; 2219 readonly elements: NodeArray<Expression>; 2220 /* @internal */ 2221 multiLine?: boolean; 2222 } 2223 2224 export interface SpreadElement extends Expression { 2225 readonly kind: SyntaxKind.SpreadElement; 2226 readonly parent: ArrayLiteralExpression | CallExpression | NewExpression; 2227 readonly expression: Expression; 2228 } 2229 2230 /** 2231 * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to 2232 * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be 2233 * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type 2234 * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) 2235 */ 2236 export interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> extends PrimaryExpression, Declaration { 2237 readonly properties: NodeArray<T>; 2238 } 2239 2240 // An ObjectLiteralExpression is the declaration node for an anonymous symbol. 2241 export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike> { 2242 readonly kind: SyntaxKind.ObjectLiteralExpression; 2243 /* @internal */ 2244 multiLine?: boolean; 2245 } 2246 2247 export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; 2248 export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; 2249 export type AccessExpression = PropertyAccessExpression | ElementAccessExpression; 2250 2251 export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { 2252 readonly kind: SyntaxKind.PropertyAccessExpression; 2253 readonly expression: LeftHandSideExpression; 2254 readonly questionDotToken?: QuestionDotToken; 2255 readonly name: Identifier | PrivateIdentifier; 2256 } 2257 2258 /*@internal*/ 2259 export interface PrivateIdentifierPropertyAccessExpression extends PropertyAccessExpression { 2260 readonly name: PrivateIdentifier; 2261 } 2262 2263 export interface PropertyAccessChain extends PropertyAccessExpression { 2264 _optionalChainBrand: any; 2265 readonly name: Identifier | PrivateIdentifier; 2266 } 2267 2268 /* @internal */ 2269 export interface PropertyAccessChainRoot extends PropertyAccessChain { 2270 readonly questionDotToken: QuestionDotToken; 2271 } 2272 2273 export interface SuperPropertyAccessExpression extends PropertyAccessExpression { 2274 readonly expression: SuperExpression; 2275 } 2276 2277 /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ 2278 export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { 2279 _propertyAccessExpressionLikeQualifiedNameBrand?: any; 2280 readonly expression: EntityNameExpression; 2281 readonly name: Identifier; 2282 } 2283 2284 export interface ElementAccessExpression extends MemberExpression { 2285 readonly kind: SyntaxKind.ElementAccessExpression; 2286 readonly expression: LeftHandSideExpression; 2287 readonly questionDotToken?: QuestionDotToken; 2288 readonly argumentExpression: Expression; 2289 } 2290 2291 export interface ElementAccessChain extends ElementAccessExpression { 2292 _optionalChainBrand: any; 2293 } 2294 2295 /* @internal */ 2296 export interface ElementAccessChainRoot extends ElementAccessChain { 2297 readonly questionDotToken: QuestionDotToken; 2298 } 2299 2300 export interface SuperElementAccessExpression extends ElementAccessExpression { 2301 readonly expression: SuperExpression; 2302 } 2303 2304 // see: https://tc39.github.io/ecma262/#prod-SuperProperty 2305 export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; 2306 2307 export interface CallExpression extends LeftHandSideExpression, Declaration { 2308 readonly kind: SyntaxKind.CallExpression; 2309 readonly expression: LeftHandSideExpression; 2310 readonly questionDotToken?: QuestionDotToken; 2311 readonly typeArguments?: NodeArray<TypeNode>; 2312 readonly arguments: NodeArray<Expression>; 2313 } 2314 2315 export interface CallChain extends CallExpression { 2316 _optionalChainBrand: any; 2317 } 2318 2319 /* @internal */ 2320 export interface CallChainRoot extends CallChain { 2321 readonly questionDotToken: QuestionDotToken; 2322 } 2323 2324 export type OptionalChain = 2325 | PropertyAccessChain 2326 | ElementAccessChain 2327 | CallChain 2328 | NonNullChain 2329 ; 2330 2331 /* @internal */ 2332 export type OptionalChainRoot = 2333 | PropertyAccessChainRoot 2334 | ElementAccessChainRoot 2335 | CallChainRoot 2336 ; 2337 2338 /** @internal */ 2339 export interface WellKnownSymbolExpression extends PropertyAccessExpression { 2340 readonly expression: Identifier & { readonly escapedText: __String & "Symbol" }; 2341 readonly name: Identifier; 2342 } 2343 2344 /** @internal */ 2345 export type BindableObjectDefinePropertyCall = CallExpression & { 2346 readonly arguments: readonly [BindableStaticNameExpression, StringLiteralLike | NumericLiteral, ObjectLiteralExpression] & Readonly<TextRange>; 2347 }; 2348 2349 /** @internal */ 2350 export type BindableStaticNameExpression = 2351 | EntityNameExpression 2352 | BindableStaticElementAccessExpression 2353 ; 2354 2355 /** @internal */ 2356 export type LiteralLikeElementAccessExpression = ElementAccessExpression & Declaration & { 2357 readonly argumentExpression: StringLiteralLike | NumericLiteral | WellKnownSymbolExpression; 2358 }; 2359 2360 /** @internal */ 2361 export type BindableStaticElementAccessExpression = LiteralLikeElementAccessExpression & { 2362 readonly expression: BindableStaticNameExpression; 2363 }; 2364 2365 /** @internal */ 2366 export type BindableElementAccessExpression = ElementAccessExpression & { 2367 readonly expression: BindableStaticNameExpression; 2368 }; 2369 2370 /** @internal */ 2371 export type BindableStaticAccessExpression = 2372 | PropertyAccessEntityNameExpression 2373 | BindableStaticElementAccessExpression 2374 ; 2375 2376 /** @internal */ 2377 export type BindableAccessExpression = 2378 | PropertyAccessEntityNameExpression 2379 | BindableElementAccessExpression 2380 ; 2381 2382 /** @internal */ 2383 export interface BindableStaticPropertyAssignmentExpression extends BinaryExpression { 2384 readonly left: BindableStaticAccessExpression; 2385 } 2386 2387 /** @internal */ 2388 export interface BindablePropertyAssignmentExpression extends BinaryExpression { 2389 readonly left: BindableAccessExpression; 2390 } 2391 2392 // see: https://tc39.github.io/ecma262/#prod-SuperCall 2393 export interface SuperCall extends CallExpression { 2394 readonly expression: SuperExpression; 2395 } 2396 2397 export interface ImportCall extends CallExpression { 2398 readonly expression: ImportExpression; 2399 } 2400 2401 export interface ExpressionWithTypeArguments extends NodeWithTypeArguments { 2402 readonly kind: SyntaxKind.ExpressionWithTypeArguments; 2403 readonly parent: HeritageClause | JSDocAugmentsTag | JSDocImplementsTag; 2404 readonly expression: LeftHandSideExpression; 2405 } 2406 2407 export interface NewExpression extends PrimaryExpression, Declaration { 2408 readonly kind: SyntaxKind.NewExpression; 2409 readonly expression: LeftHandSideExpression; 2410 readonly typeArguments?: NodeArray<TypeNode>; 2411 readonly arguments?: NodeArray<Expression>; 2412 } 2413 2414 export interface TaggedTemplateExpression extends MemberExpression { 2415 readonly kind: SyntaxKind.TaggedTemplateExpression; 2416 readonly tag: LeftHandSideExpression; 2417 readonly typeArguments?: NodeArray<TypeNode>; 2418 readonly template: TemplateLiteral; 2419 /*@internal*/ questionDotToken?: QuestionDotToken; // NOTE: Invalid syntax, only used to report a grammar error. 2420 } 2421 2422 export type CallLikeExpression = 2423 | CallExpression 2424 | NewExpression 2425 | TaggedTemplateExpression 2426 | Decorator 2427 | JsxOpeningLikeElement 2428 | EtsComponentExpression 2429 ; 2430 2431 export interface AsExpression extends Expression { 2432 readonly kind: SyntaxKind.AsExpression; 2433 readonly expression: Expression; 2434 readonly type: TypeNode; 2435 } 2436 2437 export interface TypeAssertion extends UnaryExpression { 2438 readonly kind: SyntaxKind.TypeAssertionExpression; 2439 readonly type: TypeNode; 2440 readonly expression: UnaryExpression; 2441 } 2442 2443 export type AssertionExpression = 2444 | TypeAssertion 2445 | AsExpression 2446 ; 2447 2448 export interface NonNullExpression extends LeftHandSideExpression { 2449 readonly kind: SyntaxKind.NonNullExpression; 2450 readonly expression: Expression; 2451 } 2452 2453 export interface NonNullChain extends NonNullExpression { 2454 _optionalChainBrand: any; 2455 } 2456 2457 // NOTE: MetaProperty is really a MemberExpression, but we consider it a PrimaryExpression 2458 // for the same reasons we treat NewExpression as a PrimaryExpression. 2459 export interface MetaProperty extends PrimaryExpression { 2460 readonly kind: SyntaxKind.MetaProperty; 2461 readonly keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword; 2462 readonly name: Identifier; 2463 } 2464 2465 /* @internal */ 2466 export interface ImportMetaProperty extends MetaProperty { 2467 readonly keywordToken: SyntaxKind.ImportKeyword; 2468 readonly name: Identifier & { readonly escapedText: __String & "meta" }; 2469 } 2470 2471 /// A JSX expression of the form <TagName attrs>...</TagName> 2472 export interface JsxElement extends PrimaryExpression { 2473 readonly kind: SyntaxKind.JsxElement; 2474 readonly openingElement: JsxOpeningElement; 2475 readonly children: NodeArray<JsxChild>; 2476 readonly closingElement: JsxClosingElement; 2477 } 2478 2479 /// Either the opening tag in a <Tag>...</Tag> pair or the lone <Tag /> in a self-closing form 2480 export type JsxOpeningLikeElement = 2481 | JsxSelfClosingElement 2482 | JsxOpeningElement 2483 ; 2484 2485 export type JsxAttributeLike = 2486 | JsxAttribute 2487 | JsxSpreadAttribute 2488 ; 2489 2490 export type JsxTagNameExpression = 2491 | Identifier 2492 | ThisExpression 2493 | JsxTagNamePropertyAccess 2494 ; 2495 2496 export interface JsxTagNamePropertyAccess extends PropertyAccessExpression { 2497 readonly expression: JsxTagNameExpression; 2498 } 2499 2500 export interface JsxAttributes extends ObjectLiteralExpressionBase<JsxAttributeLike> { 2501 readonly kind: SyntaxKind.JsxAttributes; 2502 readonly parent: JsxOpeningLikeElement; 2503 } 2504 2505 /// The opening element of a <Tag>...</Tag> JsxElement 2506 export interface JsxOpeningElement extends Expression { 2507 readonly kind: SyntaxKind.JsxOpeningElement; 2508 readonly parent: JsxElement; 2509 readonly tagName: JsxTagNameExpression; 2510 readonly typeArguments?: NodeArray<TypeNode>; 2511 readonly attributes: JsxAttributes; 2512 } 2513 2514 /// A JSX expression of the form <TagName attrs /> 2515 export interface JsxSelfClosingElement extends PrimaryExpression { 2516 readonly kind: SyntaxKind.JsxSelfClosingElement; 2517 readonly tagName: JsxTagNameExpression; 2518 readonly typeArguments?: NodeArray<TypeNode>; 2519 readonly attributes: JsxAttributes; 2520 } 2521 2522 /// A JSX expression of the form <>...</> 2523 export interface JsxFragment extends PrimaryExpression { 2524 readonly kind: SyntaxKind.JsxFragment; 2525 readonly openingFragment: JsxOpeningFragment; 2526 readonly children: NodeArray<JsxChild>; 2527 readonly closingFragment: JsxClosingFragment; 2528 } 2529 2530 /// The opening element of a <>...</> JsxFragment 2531 export interface JsxOpeningFragment extends Expression { 2532 readonly kind: SyntaxKind.JsxOpeningFragment; 2533 readonly parent: JsxFragment; 2534 } 2535 2536 /// The closing element of a <>...</> JsxFragment 2537 export interface JsxClosingFragment extends Expression { 2538 readonly kind: SyntaxKind.JsxClosingFragment; 2539 readonly parent: JsxFragment; 2540 } 2541 2542 export interface JsxAttribute extends ObjectLiteralElement { 2543 readonly kind: SyntaxKind.JsxAttribute; 2544 readonly parent: JsxAttributes; 2545 readonly name: Identifier; 2546 /// JSX attribute initializers are optional; <X y /> is sugar for <X y={true} /> 2547 readonly initializer?: StringLiteral | JsxExpression; 2548 } 2549 2550 export interface JsxSpreadAttribute extends ObjectLiteralElement { 2551 readonly kind: SyntaxKind.JsxSpreadAttribute; 2552 readonly parent: JsxAttributes; 2553 readonly expression: Expression; 2554 } 2555 2556 export interface JsxClosingElement extends Node { 2557 readonly kind: SyntaxKind.JsxClosingElement; 2558 readonly parent: JsxElement; 2559 readonly tagName: JsxTagNameExpression; 2560 } 2561 2562 export interface JsxExpression extends Expression { 2563 readonly kind: SyntaxKind.JsxExpression; 2564 readonly parent: JsxElement | JsxAttributeLike; 2565 readonly dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>; 2566 readonly expression?: Expression; 2567 } 2568 2569 export interface JsxText extends LiteralLikeNode { 2570 readonly kind: SyntaxKind.JsxText; 2571 readonly parent: JsxElement; 2572 readonly containsOnlyTriviaWhiteSpaces: boolean; 2573 } 2574 2575 export type JsxChild = 2576 | JsxText 2577 | JsxExpression 2578 | JsxElement 2579 | JsxSelfClosingElement 2580 | JsxFragment 2581 ; 2582 2583 export interface Statement extends Node { 2584 _statementBrand: any; 2585 } 2586 2587 // Represents a statement that is elided as part of a transformation to emit comments on a 2588 // not-emitted node. 2589 export interface NotEmittedStatement extends Statement { 2590 readonly kind: SyntaxKind.NotEmittedStatement; 2591 } 2592 2593 /** 2594 * Marks the end of transformed declaration to properly emit exports. 2595 */ 2596 /* @internal */ 2597 export interface EndOfDeclarationMarker extends Statement { 2598 readonly kind: SyntaxKind.EndOfDeclarationMarker; 2599 } 2600 2601 /** 2602 * A list of comma-separated expressions. This node is only created by transformations. 2603 */ 2604 export interface CommaListExpression extends Expression { 2605 readonly kind: SyntaxKind.CommaListExpression; 2606 readonly elements: NodeArray<Expression>; 2607 } 2608 2609 /** 2610 * Marks the beginning of a merged transformed declaration. 2611 */ 2612 /* @internal */ 2613 export interface MergeDeclarationMarker extends Statement { 2614 readonly kind: SyntaxKind.MergeDeclarationMarker; 2615 } 2616 2617 /* @internal */ 2618 export interface SyntheticReferenceExpression extends LeftHandSideExpression { 2619 readonly kind: SyntaxKind.SyntheticReferenceExpression; 2620 readonly expression: Expression; 2621 readonly thisArg: Expression; 2622 } 2623 2624 export interface EmptyStatement extends Statement { 2625 readonly kind: SyntaxKind.EmptyStatement; 2626 } 2627 2628 export interface DebuggerStatement extends Statement { 2629 readonly kind: SyntaxKind.DebuggerStatement; 2630 } 2631 2632 export interface MissingDeclaration extends DeclarationStatement { 2633 /*@internal*/ decorators?: NodeArray<Decorator>; // Present for use with reporting a grammar error 2634 /*@internal*/ modifiers?: ModifiersArray; // Present for use with reporting a grammar error 2635 readonly kind: SyntaxKind.MissingDeclaration; 2636 readonly name?: Identifier; 2637 } 2638 2639 export type BlockLike = 2640 | SourceFile 2641 | Block 2642 | ModuleBlock 2643 | CaseOrDefaultClause 2644 ; 2645 2646 export interface Block extends Statement { 2647 readonly kind: SyntaxKind.Block; 2648 readonly statements: NodeArray<Statement>; 2649 /*@internal*/ multiLine?: boolean; 2650 } 2651 2652 export interface VariableStatement extends Statement, JSDocContainer { 2653 /* @internal*/ decorators?: NodeArray<Decorator>; // Present for use with reporting a grammar error 2654 readonly kind: SyntaxKind.VariableStatement; 2655 readonly declarationList: VariableDeclarationList; 2656 } 2657 2658 export interface ExpressionStatement extends Statement, JSDocContainer { 2659 readonly kind: SyntaxKind.ExpressionStatement; 2660 readonly expression: Expression; 2661 } 2662 2663 /* @internal */ 2664 export interface PrologueDirective extends ExpressionStatement { 2665 readonly expression: StringLiteral; 2666 } 2667 2668 export interface IfStatement extends Statement { 2669 readonly kind: SyntaxKind.IfStatement; 2670 readonly expression: Expression; 2671 readonly thenStatement: Statement; 2672 readonly elseStatement?: Statement; 2673 } 2674 2675 export interface IterationStatement extends Statement { 2676 readonly statement: Statement; 2677 } 2678 2679 export interface DoStatement extends IterationStatement { 2680 readonly kind: SyntaxKind.DoStatement; 2681 readonly expression: Expression; 2682 } 2683 2684 export interface WhileStatement extends IterationStatement { 2685 readonly kind: SyntaxKind.WhileStatement; 2686 readonly expression: Expression; 2687 } 2688 2689 export type ForInitializer = 2690 | VariableDeclarationList 2691 | Expression 2692 ; 2693 2694 export interface ForStatement extends IterationStatement { 2695 readonly kind: SyntaxKind.ForStatement; 2696 readonly initializer?: ForInitializer; 2697 readonly condition?: Expression; 2698 readonly incrementor?: Expression; 2699 } 2700 2701 export type ForInOrOfStatement = 2702 | ForInStatement 2703 | ForOfStatement 2704 ; 2705 2706 export interface ForInStatement extends IterationStatement { 2707 readonly kind: SyntaxKind.ForInStatement; 2708 readonly initializer: ForInitializer; 2709 readonly expression: Expression; 2710 } 2711 2712 export interface ForOfStatement extends IterationStatement { 2713 readonly kind: SyntaxKind.ForOfStatement; 2714 readonly awaitModifier?: AwaitKeywordToken; 2715 readonly initializer: ForInitializer; 2716 readonly expression: Expression; 2717 } 2718 2719 export interface BreakStatement extends Statement { 2720 readonly kind: SyntaxKind.BreakStatement; 2721 readonly label?: Identifier; 2722 } 2723 2724 export interface ContinueStatement extends Statement { 2725 readonly kind: SyntaxKind.ContinueStatement; 2726 readonly label?: Identifier; 2727 } 2728 2729 export type BreakOrContinueStatement = 2730 | BreakStatement 2731 | ContinueStatement 2732 ; 2733 2734 export interface ReturnStatement extends Statement { 2735 readonly kind: SyntaxKind.ReturnStatement; 2736 readonly expression?: Expression; 2737 } 2738 2739 export interface WithStatement extends Statement { 2740 readonly kind: SyntaxKind.WithStatement; 2741 readonly expression: Expression; 2742 readonly statement: Statement; 2743 } 2744 2745 export interface SwitchStatement extends Statement { 2746 readonly kind: SyntaxKind.SwitchStatement; 2747 readonly expression: Expression; 2748 readonly caseBlock: CaseBlock; 2749 possiblyExhaustive?: boolean; // initialized by binding 2750 } 2751 2752 export interface CaseBlock extends Node { 2753 readonly kind: SyntaxKind.CaseBlock; 2754 readonly parent: SwitchStatement; 2755 readonly clauses: NodeArray<CaseOrDefaultClause>; 2756 } 2757 2758 export interface CaseClause extends Node { 2759 readonly kind: SyntaxKind.CaseClause; 2760 readonly parent: CaseBlock; 2761 readonly expression: Expression; 2762 readonly statements: NodeArray<Statement>; 2763 /* @internal */ fallthroughFlowNode?: FlowNode; 2764 } 2765 2766 export interface DefaultClause extends Node { 2767 readonly kind: SyntaxKind.DefaultClause; 2768 readonly parent: CaseBlock; 2769 readonly statements: NodeArray<Statement>; 2770 /* @internal */ fallthroughFlowNode?: FlowNode; 2771 } 2772 2773 export type CaseOrDefaultClause = 2774 | CaseClause 2775 | DefaultClause 2776 ; 2777 2778 export interface LabeledStatement extends Statement, JSDocContainer { 2779 readonly kind: SyntaxKind.LabeledStatement; 2780 readonly label: Identifier; 2781 readonly statement: Statement; 2782 } 2783 2784 export interface ThrowStatement extends Statement { 2785 readonly kind: SyntaxKind.ThrowStatement; 2786 readonly expression: Expression; 2787 } 2788 2789 export interface TryStatement extends Statement { 2790 readonly kind: SyntaxKind.TryStatement; 2791 readonly tryBlock: Block; 2792 readonly catchClause?: CatchClause; 2793 readonly finallyBlock?: Block; 2794 } 2795 2796 export interface CatchClause extends Node { 2797 readonly kind: SyntaxKind.CatchClause; 2798 readonly parent: TryStatement; 2799 readonly variableDeclaration?: VariableDeclaration; 2800 readonly block: Block; 2801 } 2802 2803 export type ObjectTypeDeclaration = 2804 | ClassLikeDeclaration 2805 | InterfaceDeclaration 2806 | TypeLiteralNode 2807 ; 2808 2809 export type DeclarationWithTypeParameters = 2810 | DeclarationWithTypeParameterChildren 2811 | JSDocTypedefTag 2812 | JSDocCallbackTag 2813 | JSDocSignature 2814 ; 2815 2816 export type DeclarationWithTypeParameterChildren = 2817 | SignatureDeclaration 2818 | ClassLikeDeclaration 2819 | InterfaceDeclaration 2820 | TypeAliasDeclaration 2821 | JSDocTemplateTag 2822 ; 2823 2824 export interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { 2825 readonly kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression | SyntaxKind.StructDeclaration; 2826 readonly name?: Identifier; 2827 readonly typeParameters?: NodeArray<TypeParameterDeclaration>; 2828 readonly heritageClauses?: NodeArray<HeritageClause>; 2829 readonly members: NodeArray<ClassElement>; 2830 } 2831 2832 export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { 2833 readonly kind: SyntaxKind.ClassDeclaration; 2834 /** May be undefined in `export default class { ... }`. */ 2835 readonly name?: Identifier; 2836 } 2837 2838 export interface StructDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { 2839 readonly kind: SyntaxKind.StructDeclaration; 2840 /** May be undefined in `export default class { ... }`. */ 2841 readonly name?: Identifier; 2842 } 2843 2844 export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { 2845 readonly kind: SyntaxKind.ClassExpression; 2846 } 2847 2848 export type ClassLikeDeclaration = 2849 | ClassDeclaration 2850 | ClassExpression 2851 | StructDeclaration 2852 ; 2853 2854 export interface ClassElement extends NamedDeclaration { 2855 _classElementBrand: any; 2856 readonly name?: PropertyName; 2857 } 2858 2859 export interface TypeElement extends NamedDeclaration { 2860 _typeElementBrand: any; 2861 readonly name?: PropertyName; 2862 readonly questionToken?: QuestionToken; 2863 } 2864 2865 export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { 2866 readonly kind: SyntaxKind.InterfaceDeclaration; 2867 readonly name: Identifier; 2868 readonly typeParameters?: NodeArray<TypeParameterDeclaration>; 2869 readonly heritageClauses?: NodeArray<HeritageClause>; 2870 readonly members: NodeArray<TypeElement>; 2871 } 2872 2873 export interface HeritageClause extends Node { 2874 readonly kind: SyntaxKind.HeritageClause; 2875 readonly parent: InterfaceDeclaration | ClassLikeDeclaration; 2876 readonly token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; 2877 readonly types: NodeArray<ExpressionWithTypeArguments>; 2878 } 2879 2880 export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { 2881 readonly kind: SyntaxKind.TypeAliasDeclaration; 2882 readonly name: Identifier; 2883 readonly typeParameters?: NodeArray<TypeParameterDeclaration>; 2884 readonly type: TypeNode; 2885 } 2886 2887 export interface EnumMember extends NamedDeclaration, JSDocContainer { 2888 readonly kind: SyntaxKind.EnumMember; 2889 readonly parent: EnumDeclaration; 2890 // This does include ComputedPropertyName, but the parser will give an error 2891 // if it parses a ComputedPropertyName in an EnumMember 2892 readonly name: PropertyName; 2893 readonly initializer?: Expression; 2894 } 2895 2896 export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { 2897 readonly kind: SyntaxKind.EnumDeclaration; 2898 readonly name: Identifier; 2899 readonly members: NodeArray<EnumMember>; 2900 } 2901 2902 export type ModuleName = 2903 | Identifier 2904 | StringLiteral 2905 ; 2906 2907 export type ModuleBody = 2908 | NamespaceBody 2909 | JSDocNamespaceBody 2910 ; 2911 2912 /* @internal */ 2913 export interface AmbientModuleDeclaration extends ModuleDeclaration { 2914 readonly body?: ModuleBlock; 2915 } 2916 2917 export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { 2918 readonly kind: SyntaxKind.ModuleDeclaration; 2919 readonly parent: ModuleBody | SourceFile; 2920 readonly name: ModuleName; 2921 readonly body?: ModuleBody | JSDocNamespaceDeclaration; 2922 } 2923 2924 export type NamespaceBody = 2925 | ModuleBlock 2926 | NamespaceDeclaration 2927 ; 2928 2929 export interface NamespaceDeclaration extends ModuleDeclaration { 2930 readonly name: Identifier; 2931 readonly body: NamespaceBody; 2932 } 2933 2934 export type JSDocNamespaceBody = 2935 | Identifier 2936 | JSDocNamespaceDeclaration 2937 ; 2938 2939 export interface JSDocNamespaceDeclaration extends ModuleDeclaration { 2940 readonly name: Identifier; 2941 readonly body?: JSDocNamespaceBody; 2942 } 2943 2944 export interface ModuleBlock extends Node, Statement { 2945 readonly kind: SyntaxKind.ModuleBlock; 2946 readonly parent: ModuleDeclaration; 2947 readonly statements: NodeArray<Statement>; 2948 } 2949 2950 export type ModuleReference = 2951 | EntityName 2952 | ExternalModuleReference 2953 ; 2954 2955 /** 2956 * One of: 2957 * - import x = require("mod"); 2958 * - import x = M.x; 2959 */ 2960 export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { 2961 readonly kind: SyntaxKind.ImportEqualsDeclaration; 2962 readonly parent: SourceFile | ModuleBlock; 2963 readonly name: Identifier; 2964 readonly isTypeOnly: boolean; 2965 2966 // 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external 2967 // module reference. 2968 readonly moduleReference: ModuleReference; 2969 } 2970 2971 export interface ExternalModuleReference extends Node { 2972 readonly kind: SyntaxKind.ExternalModuleReference; 2973 readonly parent: ImportEqualsDeclaration; 2974 readonly expression: Expression; 2975 } 2976 2977 // In case of: 2978 // import "mod" => importClause = undefined, moduleSpecifier = "mod" 2979 // In rest of the cases, module specifier is string literal corresponding to module 2980 // ImportClause information is shown at its declaration below. 2981 export interface ImportDeclaration extends Statement, JSDocContainer { 2982 readonly kind: SyntaxKind.ImportDeclaration; 2983 readonly parent: SourceFile | ModuleBlock; 2984 readonly importClause?: ImportClause; 2985 /** If this is not a StringLiteral it will be a grammar error. */ 2986 readonly moduleSpecifier: Expression; 2987 } 2988 2989 export type NamedImportBindings = 2990 | NamespaceImport 2991 | NamedImports 2992 ; 2993 2994 export type NamedExportBindings = 2995 | NamespaceExport 2996 | NamedExports 2997 ; 2998 2999 // In case of: 3000 // import d from "mod" => name = d, namedBinding = undefined 3001 // import * as ns from "mod" => name = undefined, namedBinding: NamespaceImport = { name: ns } 3002 // import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns } 3003 // import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} 3004 // import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} 3005 export interface ImportClause extends NamedDeclaration { 3006 readonly kind: SyntaxKind.ImportClause; 3007 readonly parent: ImportDeclaration; 3008 readonly isTypeOnly: boolean; 3009 readonly name?: Identifier; // Default binding 3010 readonly namedBindings?: NamedImportBindings; 3011 } 3012 3013 export interface NamespaceImport extends NamedDeclaration { 3014 readonly kind: SyntaxKind.NamespaceImport; 3015 readonly parent: ImportClause; 3016 readonly name: Identifier; 3017 } 3018 3019 export interface NamespaceExport extends NamedDeclaration { 3020 readonly kind: SyntaxKind.NamespaceExport; 3021 readonly parent: ExportDeclaration; 3022 readonly name: Identifier 3023 } 3024 3025 export interface NamespaceExportDeclaration extends DeclarationStatement, JSDocContainer { 3026 readonly kind: SyntaxKind.NamespaceExportDeclaration; 3027 readonly name: Identifier; 3028 /* @internal */ decorators?: NodeArray<Decorator>; // Present for use with reporting a grammar error 3029 /* @internal */ modifiers?: ModifiersArray; // Present for use with reporting a grammar error 3030 } 3031 3032 export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { 3033 readonly kind: SyntaxKind.ExportDeclaration; 3034 readonly parent: SourceFile | ModuleBlock; 3035 readonly isTypeOnly: boolean; 3036 /** Will not be assigned in the case of `export * from "foo";` */ 3037 readonly exportClause?: NamedExportBindings; 3038 /** If this is not a StringLiteral it will be a grammar error. */ 3039 readonly moduleSpecifier?: Expression; 3040 } 3041 3042 export interface NamedImports extends Node { 3043 readonly kind: SyntaxKind.NamedImports; 3044 readonly parent: ImportClause; 3045 readonly elements: NodeArray<ImportSpecifier>; 3046 } 3047 3048 export interface NamedExports extends Node { 3049 readonly kind: SyntaxKind.NamedExports; 3050 readonly parent: ExportDeclaration; 3051 readonly elements: NodeArray<ExportSpecifier>; 3052 } 3053 3054 export type NamedImportsOrExports = NamedImports | NamedExports; 3055 3056 export interface ImportSpecifier extends NamedDeclaration { 3057 readonly kind: SyntaxKind.ImportSpecifier; 3058 readonly parent: NamedImports; 3059 readonly propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) 3060 readonly name: Identifier; // Declared name 3061 } 3062 3063 export interface ExportSpecifier extends NamedDeclaration { 3064 readonly kind: SyntaxKind.ExportSpecifier; 3065 readonly parent: NamedExports; 3066 readonly propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) 3067 readonly name: Identifier; // Declared name 3068 } 3069 3070 export type ImportOrExportSpecifier = 3071 | ImportSpecifier 3072 | ExportSpecifier 3073 ; 3074 3075 export type TypeOnlyCompatibleAliasDeclaration = 3076 | ImportClause 3077 | ImportEqualsDeclaration 3078 | NamespaceImport 3079 | ImportOrExportSpecifier 3080 ; 3081 3082 /** 3083 * This is either an `export =` or an `export default` declaration. 3084 * Unless `isExportEquals` is set, this node was parsed as an `export default`. 3085 */ 3086 export interface ExportAssignment extends DeclarationStatement, JSDocContainer { 3087 readonly kind: SyntaxKind.ExportAssignment; 3088 readonly parent: SourceFile; 3089 readonly isExportEquals?: boolean; 3090 readonly expression: Expression; 3091 } 3092 3093 export interface FileReference extends TextRange { 3094 fileName: string; 3095 } 3096 3097 export interface CheckJsDirective extends TextRange { 3098 enabled: boolean; 3099 } 3100 3101 export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; 3102 3103 export interface CommentRange extends TextRange { 3104 hasTrailingNewLine?: boolean; 3105 kind: CommentKind; 3106 } 3107 3108 export interface SynthesizedComment extends CommentRange { 3109 text: string; 3110 pos: -1; 3111 end: -1; 3112 hasLeadingNewline?: boolean; 3113 } 3114 3115 // represents a top level: { type } expression in a JSDoc comment. 3116 export interface JSDocTypeExpression extends TypeNode { 3117 readonly kind: SyntaxKind.JSDocTypeExpression; 3118 readonly type: TypeNode; 3119 } 3120 3121 export interface JSDocNameReference extends Node { 3122 readonly kind: SyntaxKind.JSDocNameReference; 3123 readonly name: EntityName; 3124 } 3125 3126 export interface JSDocType extends TypeNode { 3127 _jsDocTypeBrand: any; 3128 } 3129 3130 export interface JSDocAllType extends JSDocType { 3131 readonly kind: SyntaxKind.JSDocAllType; 3132 } 3133 3134 export interface JSDocUnknownType extends JSDocType { 3135 readonly kind: SyntaxKind.JSDocUnknownType; 3136 } 3137 3138 export interface JSDocNonNullableType extends JSDocType { 3139 readonly kind: SyntaxKind.JSDocNonNullableType; 3140 readonly type: TypeNode; 3141 } 3142 3143 export interface JSDocNullableType extends JSDocType { 3144 readonly kind: SyntaxKind.JSDocNullableType; 3145 readonly type: TypeNode; 3146 } 3147 3148 export interface JSDocOptionalType extends JSDocType { 3149 readonly kind: SyntaxKind.JSDocOptionalType; 3150 readonly type: TypeNode; 3151 } 3152 3153 export interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { 3154 readonly kind: SyntaxKind.JSDocFunctionType; 3155 } 3156 3157 export interface JSDocVariadicType extends JSDocType { 3158 readonly kind: SyntaxKind.JSDocVariadicType; 3159 readonly type: TypeNode; 3160 } 3161 3162 export interface JSDocNamepathType extends JSDocType { 3163 readonly kind: SyntaxKind.JSDocNamepathType; 3164 readonly type: TypeNode; 3165 } 3166 3167 export type JSDocTypeReferencingNode = 3168 | JSDocVariadicType 3169 | JSDocOptionalType 3170 | JSDocNullableType 3171 | JSDocNonNullableType 3172 ; 3173 3174 export interface JSDoc extends Node { 3175 readonly kind: SyntaxKind.JSDocComment; 3176 readonly parent: HasJSDoc; 3177 readonly tags?: NodeArray<JSDocTag>; 3178 readonly comment?: string; 3179 } 3180 3181 export interface JSDocTag extends Node { 3182 readonly parent: JSDoc | JSDocTypeLiteral; 3183 readonly tagName: Identifier; 3184 readonly comment?: string; 3185 } 3186 3187 export interface JSDocUnknownTag extends JSDocTag { 3188 readonly kind: SyntaxKind.JSDocTag; 3189 } 3190 3191 /** 3192 * Note that `@extends` is a synonym of `@augments`. 3193 * Both tags are represented by this interface. 3194 */ 3195 export interface JSDocAugmentsTag extends JSDocTag { 3196 readonly kind: SyntaxKind.JSDocAugmentsTag; 3197 readonly class: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression }; 3198 } 3199 3200 export interface JSDocImplementsTag extends JSDocTag { 3201 readonly kind: SyntaxKind.JSDocImplementsTag; 3202 readonly class: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression }; 3203 } 3204 3205 export interface JSDocAuthorTag extends JSDocTag { 3206 readonly kind: SyntaxKind.JSDocAuthorTag; 3207 } 3208 3209 export interface JSDocDeprecatedTag extends JSDocTag { 3210 kind: SyntaxKind.JSDocDeprecatedTag; 3211 } 3212 3213 export interface JSDocClassTag extends JSDocTag { 3214 readonly kind: SyntaxKind.JSDocClassTag; 3215 } 3216 3217 export interface JSDocPublicTag extends JSDocTag { 3218 readonly kind: SyntaxKind.JSDocPublicTag; 3219 } 3220 3221 export interface JSDocPrivateTag extends JSDocTag { 3222 readonly kind: SyntaxKind.JSDocPrivateTag; 3223 } 3224 3225 export interface JSDocProtectedTag extends JSDocTag { 3226 readonly kind: SyntaxKind.JSDocProtectedTag; 3227 } 3228 3229 export interface JSDocReadonlyTag extends JSDocTag { 3230 readonly kind: SyntaxKind.JSDocReadonlyTag; 3231 } 3232 3233 export interface JSDocEnumTag extends JSDocTag, Declaration { 3234 readonly kind: SyntaxKind.JSDocEnumTag; 3235 readonly parent: JSDoc; 3236 readonly typeExpression: JSDocTypeExpression; 3237 } 3238 3239 export interface JSDocThisTag extends JSDocTag { 3240 readonly kind: SyntaxKind.JSDocThisTag; 3241 readonly typeExpression: JSDocTypeExpression; 3242 } 3243 3244 export interface JSDocTemplateTag extends JSDocTag { 3245 readonly kind: SyntaxKind.JSDocTemplateTag; 3246 readonly constraint: JSDocTypeExpression | undefined; 3247 readonly typeParameters: NodeArray<TypeParameterDeclaration>; 3248 } 3249 3250 export interface JSDocSeeTag extends JSDocTag { 3251 readonly kind: SyntaxKind.JSDocSeeTag; 3252 readonly name?: JSDocNameReference; 3253 } 3254 3255 export interface JSDocReturnTag extends JSDocTag { 3256 readonly kind: SyntaxKind.JSDocReturnTag; 3257 readonly typeExpression?: JSDocTypeExpression; 3258 } 3259 3260 export interface JSDocTypeTag extends JSDocTag { 3261 readonly kind: SyntaxKind.JSDocTypeTag; 3262 readonly typeExpression: JSDocTypeExpression; 3263 } 3264 3265 export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { 3266 readonly kind: SyntaxKind.JSDocTypedefTag; 3267 readonly parent: JSDoc; 3268 readonly fullName?: JSDocNamespaceDeclaration | Identifier; 3269 readonly name?: Identifier; 3270 readonly typeExpression?: JSDocTypeExpression | JSDocTypeLiteral; 3271 } 3272 3273 export interface JSDocCallbackTag extends JSDocTag, NamedDeclaration { 3274 readonly kind: SyntaxKind.JSDocCallbackTag; 3275 readonly parent: JSDoc; 3276 readonly fullName?: JSDocNamespaceDeclaration | Identifier; 3277 readonly name?: Identifier; 3278 readonly typeExpression: JSDocSignature; 3279 } 3280 3281 export interface JSDocSignature extends JSDocType, Declaration { 3282 readonly kind: SyntaxKind.JSDocSignature; 3283 readonly typeParameters?: readonly JSDocTemplateTag[]; 3284 readonly parameters: readonly JSDocParameterTag[]; 3285 readonly type: JSDocReturnTag | undefined; 3286 } 3287 3288 export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { 3289 readonly parent: JSDoc; 3290 readonly name: EntityName; 3291 readonly typeExpression?: JSDocTypeExpression; 3292 /** Whether the property name came before the type -- non-standard for JSDoc, but Typescript-like */ 3293 readonly isNameFirst: boolean; 3294 readonly isBracketed: boolean; 3295 } 3296 3297 export interface JSDocPropertyTag extends JSDocPropertyLikeTag { 3298 readonly kind: SyntaxKind.JSDocPropertyTag; 3299 } 3300 3301 export interface JSDocParameterTag extends JSDocPropertyLikeTag { 3302 readonly kind: SyntaxKind.JSDocParameterTag; 3303 } 3304 3305 export interface JSDocTypeLiteral extends JSDocType { 3306 readonly kind: SyntaxKind.JSDocTypeLiteral; 3307 readonly jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; 3308 /** If true, then this type literal represents an *array* of its type. */ 3309 readonly isArrayType: boolean; 3310 } 3311 3312 // NOTE: Ensure this is up-to-date with src/debug/debug.ts 3313 export const enum FlowFlags { 3314 Unreachable = 1 << 0, // Unreachable code 3315 Start = 1 << 1, // Start of flow graph 3316 BranchLabel = 1 << 2, // Non-looping junction 3317 LoopLabel = 1 << 3, // Looping junction 3318 Assignment = 1 << 4, // Assignment 3319 TrueCondition = 1 << 5, // Condition known to be true 3320 FalseCondition = 1 << 6, // Condition known to be false 3321 SwitchClause = 1 << 7, // Switch statement clause 3322 ArrayMutation = 1 << 8, // Potential array mutation 3323 Call = 1 << 9, // Potential assertion call 3324 ReduceLabel = 1 << 10, // Temporarily reduce antecedents of label 3325 Referenced = 1 << 11, // Referenced as antecedent once 3326 Shared = 1 << 12, // Referenced as antecedent more than once 3327 3328 Label = BranchLabel | LoopLabel, 3329 Condition = TrueCondition | FalseCondition, 3330 } 3331 3332 export type FlowNode = 3333 | FlowStart 3334 | FlowLabel 3335 | FlowAssignment 3336 | FlowCall 3337 | FlowCondition 3338 | FlowSwitchClause 3339 | FlowArrayMutation 3340 | FlowCall 3341 | FlowReduceLabel; 3342 3343 export interface FlowNodeBase { 3344 flags: FlowFlags; 3345 id?: number; // Node id used by flow type cache in checker 3346 } 3347 3348 // FlowStart represents the start of a control flow. For a function expression or arrow 3349 // function, the node property references the function (which in turn has a flowNode 3350 // property for the containing control flow). 3351 export interface FlowStart extends FlowNodeBase { 3352 node?: FunctionExpression | ArrowFunction | MethodDeclaration; 3353 } 3354 3355 // FlowLabel represents a junction with multiple possible preceding control flows. 3356 export interface FlowLabel extends FlowNodeBase { 3357 antecedents: FlowNode[] | undefined; 3358 } 3359 3360 // FlowAssignment represents a node that assigns a value to a narrowable reference, 3361 // i.e. an identifier or a dotted name that starts with an identifier or 'this'. 3362 export interface FlowAssignment extends FlowNodeBase { 3363 node: Expression | VariableDeclaration | BindingElement; 3364 antecedent: FlowNode; 3365 } 3366 3367 export interface FlowCall extends FlowNodeBase { 3368 node: CallExpression; 3369 antecedent: FlowNode; 3370 } 3371 3372 // FlowCondition represents a condition that is known to be true or false at the 3373 // node's location in the control flow. 3374 export interface FlowCondition extends FlowNodeBase { 3375 node: Expression; 3376 antecedent: FlowNode; 3377 } 3378 3379 export interface FlowSwitchClause extends FlowNodeBase { 3380 switchStatement: SwitchStatement; 3381 clauseStart: number; // Start index of case/default clause range 3382 clauseEnd: number; // End index of case/default clause range 3383 antecedent: FlowNode; 3384 } 3385 3386 // FlowArrayMutation represents a node potentially mutates an array, i.e. an 3387 // operation of the form 'x.push(value)', 'x.unshift(value)' or 'x[n] = value'. 3388 export interface FlowArrayMutation extends FlowNodeBase { 3389 node: CallExpression | BinaryExpression; 3390 antecedent: FlowNode; 3391 } 3392 3393 export interface FlowReduceLabel extends FlowNodeBase { 3394 target: FlowLabel; 3395 antecedents: FlowNode[]; 3396 antecedent: FlowNode; 3397 } 3398 3399 export type FlowType = Type | IncompleteType; 3400 3401 // Incomplete types occur during control flow analysis of loops. An IncompleteType 3402 // is distinguished from a regular type by a flags value of zero. Incomplete type 3403 // objects are internal to the getFlowTypeOfReference function and never escape it. 3404 export interface IncompleteType { 3405 flags: TypeFlags; // No flags set 3406 type: Type; // The type marked incomplete 3407 } 3408 3409 export interface AmdDependency { 3410 path: string; 3411 name?: string; 3412 } 3413 3414 /* @internal */ 3415 /** 3416 * Subset of properties from SourceFile that are used in multiple utility functions 3417 */ 3418 export interface SourceFileLike { 3419 readonly text: string; 3420 lineMap?: readonly number[]; 3421 readonly fileName?: string; 3422 /* @internal */ 3423 getPositionOfLineAndCharacter?(line: number, character: number, allowEdits?: true): number; 3424 } 3425 3426 3427 /* @internal */ 3428 export interface RedirectInfo { 3429 /** Source file this redirects to. */ 3430 readonly redirectTarget: SourceFile; 3431 /** 3432 * Source file for the duplicate package. This will not be used by the Program, 3433 * but we need to keep this around so we can watch for changes in underlying. 3434 */ 3435 readonly unredirected: SourceFile; 3436 } 3437 3438 // Source files are declarations when they are external modules. 3439 export interface SourceFile extends Declaration { 3440 readonly kind: SyntaxKind.SourceFile; 3441 readonly statements: NodeArray<Statement>; 3442 readonly endOfFileToken: Token<SyntaxKind.EndOfFileToken>; 3443 3444 fileName: string; 3445 /* @internal */ path: Path; 3446 text: string; 3447 /** Resolved path can be different from path property, 3448 * when file is included through project reference is mapped to its output instead of source 3449 * in that case resolvedPath = path to output file 3450 * path = input file's path 3451 */ 3452 /* @internal */ resolvedPath: Path; 3453 /** Original file name that can be different from fileName, 3454 * when file is included through project reference is mapped to its output instead of source 3455 * in that case originalFileName = name of input file 3456 * fileName = output file's name 3457 */ 3458 /* @internal */ originalFileName: string; 3459 3460 /** 3461 * If two source files are for the same version of the same package, one will redirect to the other. 3462 * (See `createRedirectSourceFile` in program.ts.) 3463 * The redirect will have this set. The redirected-to source file will be in `redirectTargetsMap`. 3464 */ 3465 /* @internal */ redirectInfo?: RedirectInfo; 3466 3467 amdDependencies: readonly AmdDependency[]; 3468 moduleName?: string; 3469 referencedFiles: readonly FileReference[]; 3470 typeReferenceDirectives: readonly FileReference[]; 3471 libReferenceDirectives: readonly FileReference[]; 3472 languageVariant: LanguageVariant; 3473 isDeclarationFile: boolean; 3474 3475 // this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling) 3476 /* @internal */ 3477 renamedDependencies?: ReadonlyESMap<string, string>; 3478 3479 /** 3480 * lib.d.ts should have a reference comment like 3481 * 3482 * /// <reference no-default-lib="true"/> 3483 * 3484 * If any other file has this comment, it signals not to include lib.d.ts 3485 * because this containing file is intended to act as a default library. 3486 */ 3487 hasNoDefaultLib: boolean; 3488 3489 languageVersion: ScriptTarget; 3490 /* @internal */ scriptKind: ScriptKind; 3491 3492 /** 3493 * The first "most obvious" node that makes a file an external module. 3494 * This is intended to be the first top-level import/export, 3495 * but could be arbitrarily nested (e.g. `import.meta`). 3496 */ 3497 /* @internal */ externalModuleIndicator?: Node; 3498 // The first node that causes this file to be a CommonJS module 3499 /* @internal */ commonJsModuleIndicator?: Node; 3500 // JS identifier-declarations that are intended to merge with globals 3501 /* @internal */ jsGlobalAugmentations?: SymbolTable; 3502 3503 /* @internal */ identifiers: ESMap<string, string>; // Map from a string to an interned string 3504 /* @internal */ nodeCount: number; 3505 /* @internal */ identifierCount: number; 3506 /* @internal */ symbolCount: number; 3507 3508 // File-level diagnostics reported by the parser (includes diagnostics about /// references 3509 // as well as code diagnostics). 3510 /* @internal */ parseDiagnostics: DiagnosticWithLocation[]; 3511 3512 // File-level diagnostics reported by the binder. 3513 /* @internal */ bindDiagnostics: DiagnosticWithLocation[]; 3514 /* @internal */ bindSuggestionDiagnostics?: DiagnosticWithLocation[]; 3515 3516 // File-level JSDoc diagnostics reported by the JSDoc parser 3517 /* @internal */ jsDocDiagnostics?: DiagnosticWithLocation[]; 3518 3519 // Stores additional file-level diagnostics reported by the program 3520 /* @internal */ additionalSyntacticDiagnostics?: readonly DiagnosticWithLocation[]; 3521 3522 // Stores a line map for the file. 3523 // This field should never be used directly to obtain line map, use getLineMap function instead. 3524 /* @internal */ lineMap: readonly number[]; 3525 /* @internal */ classifiableNames?: ReadonlySet<__String>; 3526 // Comments containing @ts-* directives, in order. 3527 /* @internal */ commentDirectives?: CommentDirective[]; 3528 // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined 3529 // It is used to resolve module names in the checker. 3530 // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead 3531 /* @internal */ resolvedModules?: ESMap<string, ResolvedModuleFull | undefined>; 3532 /* @internal */ resolvedTypeReferenceDirectiveNames: ESMap<string, ResolvedTypeReferenceDirective | undefined>; 3533 /* @internal */ imports: readonly StringLiteralLike[]; 3534 // Identifier only if `declare global` 3535 /* @internal */ moduleAugmentations: readonly (StringLiteral | Identifier)[]; 3536 /* @internal */ patternAmbientModules?: PatternAmbientModule[]; 3537 /* @internal */ ambientModuleNames: readonly string[]; 3538 /* @internal */ checkJsDirective?: CheckJsDirective; 3539 /* @internal */ version: string; 3540 /* @internal */ pragmas: ReadonlyPragmaMap; 3541 /* @internal */ localJsxNamespace?: __String; 3542 /* @internal */ localJsxFragmentNamespace?: __String; 3543 /* @internal */ localJsxFactory?: EntityName; 3544 /* @internal */ localJsxFragmentFactory?: EntityName; 3545 3546 /* @internal */ exportedModulesFromDeclarationEmit?: ExportedModulesFromDeclarationEmit; 3547 } 3548 3549 /* @internal */ 3550 export interface CommentDirective { 3551 range: TextRange; 3552 type: CommentDirectiveType, 3553 } 3554 3555 /* @internal */ 3556 export const enum CommentDirectiveType { 3557 ExpectError, 3558 Ignore, 3559 } 3560 3561 /*@internal*/ 3562 export type ExportedModulesFromDeclarationEmit = readonly Symbol[]; 3563 3564 export interface Bundle extends Node { 3565 readonly kind: SyntaxKind.Bundle; 3566 readonly prepends: readonly (InputFiles | UnparsedSource)[]; 3567 readonly sourceFiles: readonly SourceFile[]; 3568 /* @internal */ syntheticFileReferences?: readonly FileReference[]; 3569 /* @internal */ syntheticTypeReferences?: readonly FileReference[]; 3570 /* @internal */ syntheticLibReferences?: readonly FileReference[]; 3571 /* @internal */ hasNoDefaultLib?: boolean; 3572 } 3573 3574 export interface InputFiles extends Node { 3575 readonly kind: SyntaxKind.InputFiles; 3576 javascriptPath?: string; 3577 javascriptText: string; 3578 javascriptMapPath?: string; 3579 javascriptMapText?: string; 3580 declarationPath?: string; 3581 declarationText: string; 3582 declarationMapPath?: string; 3583 declarationMapText?: string; 3584 /*@internal*/ buildInfoPath?: string; 3585 /*@internal*/ buildInfo?: BuildInfo; 3586 /*@internal*/ oldFileOfCurrentEmit?: boolean; 3587 } 3588 3589 export interface UnparsedSource extends Node { 3590 readonly kind: SyntaxKind.UnparsedSource; 3591 fileName: string; 3592 text: string; 3593 readonly prologues: readonly UnparsedPrologue[]; 3594 helpers: readonly UnscopedEmitHelper[] | undefined; 3595 3596 // References and noDefaultLibAre Dts only 3597 referencedFiles: readonly FileReference[]; 3598 typeReferenceDirectives: readonly string[] | undefined; 3599 libReferenceDirectives: readonly FileReference[]; 3600 hasNoDefaultLib?: boolean; 3601 3602 sourceMapPath?: string; 3603 sourceMapText?: string; 3604 readonly syntheticReferences?: readonly UnparsedSyntheticReference[]; 3605 readonly texts: readonly UnparsedSourceText[]; 3606 /*@internal*/ oldFileOfCurrentEmit?: boolean; 3607 /*@internal*/ parsedSourceMap?: RawSourceMap | false | undefined; 3608 // Adding this to satisfy services, fix later 3609 /*@internal*/ 3610 getLineAndCharacterOfPosition(pos: number): LineAndCharacter; 3611 } 3612 3613 export type UnparsedSourceText = 3614 | UnparsedPrepend 3615 | UnparsedTextLike 3616 ; 3617 3618 export type UnparsedNode = 3619 | UnparsedPrologue 3620 | UnparsedSourceText 3621 | UnparsedSyntheticReference 3622 ; 3623 3624 export interface UnparsedSection extends Node { 3625 readonly kind: SyntaxKind; 3626 readonly parent: UnparsedSource; 3627 readonly data?: string; 3628 } 3629 3630 export interface UnparsedPrologue extends UnparsedSection { 3631 readonly kind: SyntaxKind.UnparsedPrologue; 3632 readonly parent: UnparsedSource; 3633 readonly data: string; 3634 } 3635 3636 export interface UnparsedPrepend extends UnparsedSection { 3637 readonly kind: SyntaxKind.UnparsedPrepend; 3638 readonly parent: UnparsedSource; 3639 readonly data: string; 3640 readonly texts: readonly UnparsedTextLike[]; 3641 } 3642 3643 export interface UnparsedTextLike extends UnparsedSection { 3644 readonly kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; 3645 readonly parent: UnparsedSource; 3646 } 3647 3648 export interface UnparsedSyntheticReference extends UnparsedSection { 3649 readonly kind: SyntaxKind.UnparsedSyntheticReference; 3650 readonly parent: UnparsedSource; 3651 /*@internal*/ readonly section: BundleFileHasNoDefaultLib | BundleFileReference; 3652 } 3653 3654 export interface JsonSourceFile extends SourceFile { 3655 readonly statements: NodeArray<JsonObjectExpressionStatement>; 3656 } 3657 3658 export interface TsConfigSourceFile extends JsonSourceFile { 3659 extendedSourceFiles?: string[]; 3660 /*@internal*/ configFileSpecs?: ConfigFileSpecs; 3661 } 3662 3663 export interface JsonMinusNumericLiteral extends PrefixUnaryExpression { 3664 readonly kind: SyntaxKind.PrefixUnaryExpression; 3665 readonly operator: SyntaxKind.MinusToken; 3666 readonly operand: NumericLiteral; 3667 } 3668 3669 export type JsonObjectExpression = 3670 | ObjectLiteralExpression 3671 | ArrayLiteralExpression 3672 | JsonMinusNumericLiteral 3673 | NumericLiteral 3674 | StringLiteral 3675 | BooleanLiteral 3676 | NullLiteral 3677 ; 3678 3679 export interface JsonObjectExpressionStatement extends ExpressionStatement { 3680 readonly expression: JsonObjectExpression; 3681 } 3682 3683 export interface ScriptReferenceHost { 3684 getCompilerOptions(): CompilerOptions; 3685 getSourceFile(fileName: string): SourceFile | undefined; 3686 getSourceFileByPath(path: Path): SourceFile | undefined; 3687 getCurrentDirectory(): string; 3688 } 3689 3690 export interface ParseConfigHost { 3691 useCaseSensitiveFileNames: boolean; 3692 3693 readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; 3694 3695 /** 3696 * Gets a value indicating whether the specified path exists and is a file. 3697 * @param path The path to test. 3698 */ 3699 fileExists(path: string): boolean; 3700 3701 readFile(path: string): string | undefined; 3702 trace?(s: string): void; 3703 } 3704 3705 /** 3706 * Branded string for keeping track of when we've turned an ambiguous path 3707 * specified like "./blah" to an absolute path to an actual 3708 * tsconfig file, e.g. "/root/blah/tsconfig.json" 3709 */ 3710 export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never }; 3711 3712 export type WriteFileCallback = ( 3713 fileName: string, 3714 data: string, 3715 writeByteOrderMark: boolean, 3716 onError?: (message: string) => void, 3717 sourceFiles?: readonly SourceFile[], 3718 ) => void; 3719 3720 export class OperationCanceledException { } 3721 3722 export interface CancellationToken { 3723 isCancellationRequested(): boolean; 3724 3725 /** @throws OperationCanceledException if isCancellationRequested is true */ 3726 throwIfCancellationRequested(): void; 3727 } 3728 3729 /*@internal*/ 3730 export enum FileIncludeKind { 3731 RootFile, 3732 SourceFromProjectReference, 3733 OutputFromProjectReference, 3734 Import, 3735 ReferenceFile, 3736 TypeReferenceDirective, 3737 LibFile, 3738 LibReferenceDirective, 3739 AutomaticTypeDirectiveFile 3740 } 3741 3742 /*@internal*/ 3743 export interface RootFile { 3744 kind: FileIncludeKind.RootFile, 3745 index: number; 3746 } 3747 3748 /*@internal*/ 3749 export interface LibFile { 3750 kind: FileIncludeKind.LibFile; 3751 index?: number; 3752 } 3753 3754 /*@internal*/ 3755 export type ProjectReferenceFileKind = FileIncludeKind.SourceFromProjectReference | 3756 FileIncludeKind.OutputFromProjectReference; 3757 3758 /*@internal*/ 3759 export interface ProjectReferenceFile { 3760 kind: ProjectReferenceFileKind; 3761 index: number; 3762 } 3763 3764 /*@internal*/ 3765 export type ReferencedFileKind = FileIncludeKind.Import | 3766 FileIncludeKind.ReferenceFile | 3767 FileIncludeKind.TypeReferenceDirective | 3768 FileIncludeKind.LibReferenceDirective; 3769 3770 /*@internal*/ 3771 export interface ReferencedFile { 3772 kind: ReferencedFileKind; 3773 file: Path; 3774 index: number; 3775 } 3776 3777 /*@internal*/ 3778 export interface AutomaticTypeDirectiveFile { 3779 kind: FileIncludeKind.AutomaticTypeDirectiveFile; 3780 typeReference: string; 3781 packageId: PackageId | undefined; 3782 } 3783 3784 /*@internal*/ 3785 export type FileIncludeReason = 3786 RootFile | 3787 LibFile | 3788 ProjectReferenceFile | 3789 ReferencedFile | 3790 AutomaticTypeDirectiveFile; 3791 3792 /*@internal*/ 3793 export const enum FilePreprocessingDiagnosticsKind { 3794 FilePreprocessingReferencedDiagnostic, 3795 FilePreprocessingFileExplainingDiagnostic 3796 } 3797 3798 /*@internal*/ 3799 export interface FilePreprocessingReferencedDiagnostic { 3800 kind: FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic; 3801 reason: ReferencedFile; 3802 diagnostic: DiagnosticMessage; 3803 args?: (string | number | undefined)[]; 3804 } 3805 3806 /*@internal*/ 3807 export interface FilePreprocessingFileExplainingDiagnostic { 3808 kind: FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic; 3809 file?: Path; 3810 fileProcessingReason: FileIncludeReason; 3811 diagnostic: DiagnosticMessage; 3812 args?: (string | number | undefined)[]; 3813 } 3814 3815 /*@internal*/ 3816 export type FilePreprocessingDiagnostics = FilePreprocessingReferencedDiagnostic | FilePreprocessingFileExplainingDiagnostic; 3817 3818 export interface Program extends ScriptReferenceHost { 3819 getCurrentDirectory(): string; 3820 /** 3821 * Get a list of root file names that were passed to a 'createProgram' 3822 */ 3823 getRootFileNames(): readonly string[]; 3824 3825 /** 3826 * Get a list of files in the program 3827 */ 3828 getSourceFiles(): readonly SourceFile[]; 3829 3830 /** 3831 * Get a list of file names that were passed to 'createProgram' or referenced in a 3832 * program source file but could not be located. 3833 */ 3834 /* @internal */ 3835 getMissingFilePaths(): readonly Path[]; 3836 /* @internal */ 3837 getFilesByNameMap(): ESMap<string, SourceFile | false | undefined>; 3838 3839 /** 3840 * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then 3841 * the JavaScript and declaration files will be produced for all the files in this program. 3842 * If targetSourceFile is specified, then only the JavaScript and declaration for that 3843 * specific file will be generated. 3844 * 3845 * If writeFile is not specified then the writeFile callback from the compiler host will be 3846 * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter 3847 * will be invoked when writing the JavaScript and declaration files. 3848 */ 3849 emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; 3850 /*@internal*/ 3851 emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers, forceDtsEmit?: boolean): EmitResult; // eslint-disable-line @typescript-eslint/unified-signatures 3852 3853 getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; 3854 getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; 3855 getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; 3856 /** The first time this is called, it will return global diagnostics (no location). */ 3857 getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; 3858 getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; 3859 getConfigFileParsingDiagnostics(): readonly Diagnostic[]; 3860 /* @internal */ getSuggestionDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; 3861 3862 /* @internal */ getBindAndCheckDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; 3863 /* @internal */ getProgramDiagnostics(sourceFile: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; 3864 3865 getEtsLibSFromProgram(): string[]; 3866 /** 3867 * Gets a type checker that can be used to semantically analyze source files in the program. 3868 */ 3869 getTypeChecker(): TypeChecker; 3870 3871 /* @internal */ getCommonSourceDirectory(): string; 3872 3873 // For testing purposes only. Should not be used by any other consumers (including the 3874 // language service). 3875 /* @internal */ getDiagnosticsProducingTypeChecker(): TypeChecker; 3876 /* @internal */ dropDiagnosticsProducingTypeChecker(): void; 3877 3878 /* @internal */ getCachedSemanticDiagnostics(sourceFile?: SourceFile): readonly Diagnostic[] | undefined; 3879 3880 /* @internal */ getClassifiableNames(): Set<__String>; 3881 3882 getTypeCatalog(): readonly Type[]; 3883 3884 getNodeCount(): number; 3885 getIdentifierCount(): number; 3886 getSymbolCount(): number; 3887 getTypeCount(): number; 3888 getInstantiationCount(): number; 3889 getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number }; 3890 3891 /* @internal */ getFileProcessingDiagnostics(): FilePreprocessingDiagnostics[] | undefined; 3892 /* @internal */ getResolvedTypeReferenceDirectives(): ESMap<string, ResolvedTypeReferenceDirective | undefined>; 3893 isSourceFileFromExternalLibrary(file: SourceFile): boolean; 3894 isSourceFileDefaultLibrary(file: SourceFile): boolean; 3895 3896 // For testing purposes only. 3897 // This is set on created program to let us know how the program was created using old program 3898 /* @internal */ readonly structureIsReused: StructureIsReused; 3899 3900 getSourceFileFromReference(referencingFile: SourceFile | UnparsedSource, ref: FileReference): SourceFile | undefined; 3901 /* @internal */ getLibFileFromReference(ref: FileReference): SourceFile | undefined; 3902 3903 /** Given a source file, get the name of the package it was imported from. */ 3904 /* @internal */ sourceFileToPackageName: ESMap<string, string>; 3905 /** Set of all source files that some other source file redirects to. */ 3906 /* @internal */ redirectTargetsMap: MultiMap<string, string>; 3907 /** Is the file emitted file */ 3908 /* @internal */ isEmittedFile(file: string): boolean; 3909 /* @internal */ getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>; 3910 /* @internal */ useCaseSensitiveFileNames(): boolean; 3911 3912 /* @internal */ getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; 3913 3914 getProjectReferences(): readonly ProjectReference[] | undefined; 3915 getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; 3916 /*@internal*/ getProjectReferenceRedirect(fileName: string): string | undefined; 3917 /*@internal*/ getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined; 3918 /*@internal*/ forEachResolvedProjectReference<T>(cb: (resolvedProjectReference: ResolvedProjectReference) => T | undefined): T | undefined; 3919 /*@internal*/ getResolvedProjectReferenceByPath(projectReferencePath: Path): ResolvedProjectReference | undefined; 3920 /*@internal*/ isSourceOfProjectReferenceRedirect(fileName: string): boolean; 3921 /*@internal*/ getProgramBuildInfo?(): ProgramBuildInfo | undefined; 3922 /*@internal*/ emitBuildInfo(writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; 3923 /** 3924 * This implementation handles file exists to be true if file is source of project reference redirect when program is created using useSourceOfProjectReferenceRedirect 3925 */ 3926 /*@internal*/ fileExists(fileName: string): boolean; 3927 getTagNameNeededCheckByFile?(containFilePath: string, sourceFilePath: string): TagCheckParam; 3928 getExpressionCheckedResultsByFile?(filePath: string, jsDocs: JSDocTagInfo[]): ConditionCheckResult; 3929 } 3930 3931 /*@internal*/ 3932 export interface Program extends TypeCheckerHost, ModuleSpecifierResolutionHost { 3933 } 3934 3935 export type RedirectTargetsMap = ReadonlyESMap<string, readonly string[]>; 3936 3937 export interface ResolvedProjectReference { 3938 commandLine: ParsedCommandLine; 3939 sourceFile: SourceFile; 3940 references?: readonly (ResolvedProjectReference | undefined)[]; 3941 } 3942 3943 /* @internal */ 3944 export const enum StructureIsReused { 3945 Not = 0, 3946 SafeModules = 1 << 0, 3947 Completely = 1 << 1, 3948 } 3949 3950 export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; 3951 3952 export interface CustomTransformer { 3953 transformSourceFile(node: SourceFile): SourceFile; 3954 transformBundle(node: Bundle): Bundle; 3955 } 3956 3957 export interface CustomTransformers { 3958 /** Custom transformers to evaluate before built-in .js transformations. */ 3959 before?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[]; 3960 /** Custom transformers to evaluate after built-in .js transformations. */ 3961 after?: (TransformerFactory<SourceFile> | CustomTransformerFactory)[]; 3962 /** Custom transformers to evaluate after built-in .d.ts transformations. */ 3963 afterDeclarations?: (TransformerFactory<Bundle | SourceFile> | CustomTransformerFactory)[]; 3964 } 3965 3966 /*@internal*/ 3967 export interface EmitTransformers { 3968 scriptTransformers: readonly TransformerFactory<SourceFile | Bundle>[]; 3969 declarationTransformers: readonly TransformerFactory<SourceFile | Bundle>[]; 3970 } 3971 3972 export interface SourceMapSpan { 3973 /** Line number in the .js file. */ 3974 emittedLine: number; 3975 /** Column number in the .js file. */ 3976 emittedColumn: number; 3977 /** Line number in the .ts file. */ 3978 sourceLine: number; 3979 /** Column number in the .ts file. */ 3980 sourceColumn: number; 3981 /** Optional name (index into names array) associated with this span. */ 3982 nameIndex?: number; 3983 /** .ts file (index into sources array) associated with this span */ 3984 sourceIndex: number; 3985 } 3986 3987 /* @internal */ 3988 export interface SourceMapEmitResult { 3989 inputSourceFileNames: readonly string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMap.sources list 3990 sourceMap: RawSourceMap; 3991 } 3992 3993 /** Return code used by getEmitOutput function to indicate status of the function */ 3994 export enum ExitStatus { 3995 // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, 3996 // when -version or -help was provided, or this was a normal compilation, no diagnostics 3997 // were produced, and all outputs were generated successfully. 3998 Success = 0, 3999 4000 // Diagnostics were produced and because of them no code was generated. 4001 DiagnosticsPresent_OutputsSkipped = 1, 4002 4003 // Diagnostics were produced and outputs were generated in spite of them. 4004 DiagnosticsPresent_OutputsGenerated = 2, 4005 4006 // When build skipped because passed in project is invalid 4007 InvalidProject_OutputsSkipped = 3, 4008 4009 // When build is skipped because project references form cycle 4010 ProjectReferenceCycle_OutputsSkipped = 4, 4011 4012 /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ 4013 ProjectReferenceCycle_OutputsSkupped = 4, 4014 } 4015 4016 export interface EmitResult { 4017 emitSkipped: boolean; 4018 /** Contains declaration emit diagnostics */ 4019 diagnostics: readonly Diagnostic[]; 4020 emittedFiles?: string[]; // Array of files the compiler wrote to disk 4021 /* @internal */ sourceMaps?: SourceMapEmitResult[]; // Array of sourceMapData if compiler emitted sourcemaps 4022 /* @internal */ exportedModulesFromDeclarationEmit?: ExportedModulesFromDeclarationEmit; 4023 } 4024 4025 /* @internal */ 4026 export interface TypeCheckerHost extends ModuleSpecifierResolutionHost { 4027 getCompilerOptions(): CompilerOptions; 4028 4029 getSourceFiles(): readonly SourceFile[]; 4030 getSourceFile(fileName: string): SourceFile | undefined; 4031 getResolvedTypeReferenceDirectives(): ReadonlyESMap<string, ResolvedTypeReferenceDirective | undefined>; 4032 getProjectReferenceRedirect(fileName: string): string | undefined; 4033 isSourceOfProjectReferenceRedirect(fileName: string): boolean; 4034 getTagNameNeededCheckByFile?(containFilePath: string, sourceFilePath: string): TagCheckParam; 4035 getExpressionCheckedResultsByFile?(filePath: string, jsDocs: JSDocTagInfo[]): ConditionCheckResult; 4036 4037 readonly redirectTargetsMap: RedirectTargetsMap; 4038 } 4039 4040 export interface TypeChecker { 4041 getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; 4042 getDeclaredTypeOfSymbol(symbol: Symbol): Type; 4043 getPropertiesOfType(type: Type): Symbol[]; 4044 getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; 4045 getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined; 4046 /* @internal */ getTypeOfPropertyOfType(type: Type, propertyName: string): Type | undefined; 4047 getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; 4048 getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; 4049 getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; 4050 getBaseTypes(type: InterfaceType): BaseType[]; 4051 getBaseTypeOfLiteralType(type: Type): Type; 4052 getWidenedType(type: Type): Type; 4053 /* @internal */ 4054 getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type | undefined; 4055 /* @internal */ 4056 getAwaitedType(type: Type): Type | undefined; 4057 getReturnTypeOfSignature(signature: Signature): Type; 4058 /** 4059 * Gets the type of a parameter at a given position in a signature. 4060 * Returns `any` if the index is not valid. 4061 */ 4062 /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; 4063 getNullableType(type: Type, flags: TypeFlags): Type; 4064 getNonNullableType(type: Type): Type; 4065 /* @internal */ getNonOptionalType(type: Type): Type; 4066 /* @internal */ isNullableType(type: Type): boolean; 4067 getTypeArguments(type: TypeReference): readonly Type[]; 4068 4069 // TODO: GH#18217 `xToDeclaration` calls are frequently asserted as defined. 4070 /** Note that the resulting nodes cannot be checked. */ 4071 typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeNode | undefined; 4072 /* @internal */ typeToTypeNode(type: Type, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): TypeNode | undefined; // eslint-disable-line @typescript-eslint/unified-signatures 4073 /** Note that the resulting nodes cannot be checked. */ 4074 signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): SignatureDeclaration & {typeArguments?: NodeArray<TypeNode>} | undefined; 4075 /* @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): SignatureDeclaration & {typeArguments?: NodeArray<TypeNode>} | undefined; // eslint-disable-line @typescript-eslint/unified-signatures 4076 /** Note that the resulting nodes cannot be checked. */ 4077 indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): IndexSignatureDeclaration | undefined; 4078 /* @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures 4079 /** Note that the resulting nodes cannot be checked. */ 4080 symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): EntityName | undefined; 4081 /** Note that the resulting nodes cannot be checked. */ 4082 symbolToExpression(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): Expression | undefined; 4083 /** Note that the resulting nodes cannot be checked. */ 4084 symbolToTypeParameterDeclarations(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeArray<TypeParameterDeclaration> | undefined; 4085 /** Note that the resulting nodes cannot be checked. */ 4086 symbolToParameterDeclaration(symbol: Symbol, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): ParameterDeclaration | undefined; 4087 /** Note that the resulting nodes cannot be checked. */ 4088 typeParameterToDeclaration(parameter: TypeParameter, enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): TypeParameterDeclaration | undefined; 4089 4090 getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; 4091 getSymbolAtLocation(node: Node): Symbol | undefined; 4092 getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; 4093 /** 4094 * The function returns the value (local variable) symbol of an identifier in the short-hand property assignment. 4095 * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. 4096 */ 4097 getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; 4098 4099 getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; 4100 /** 4101 * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. 4102 * Otherwise returns its input. 4103 * For example, at `export type T = number;`: 4104 * - `getSymbolAtLocation` at the location `T` will return the exported symbol for `T`. 4105 * - But the result of `getSymbolsInScope` will contain the *local* symbol for `T`, not the exported symbol. 4106 * - Calling `getExportSymbolOfSymbol` on that local symbol will return the exported symbol. 4107 */ 4108 getExportSymbolOfSymbol(symbol: Symbol): Symbol; 4109 getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; 4110 getTypeOfAssignmentPattern(pattern: AssignmentPattern): Type; 4111 getTypeAtLocation(node: Node): Type; 4112 tryGetTypeAtLocationWithoutCheck(node: Node): Type; 4113 getTypeFromTypeNode(node: TypeNode): Type; 4114 4115 signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; 4116 typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; 4117 symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): string; 4118 typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; 4119 4120 /* @internal */ writeSignature(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind, writer?: EmitTextWriter): string; 4121 /* @internal */ writeType(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; 4122 /* @internal */ writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags, writer?: EmitTextWriter): string; 4123 /* @internal */ writeTypePredicate(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags, writer?: EmitTextWriter): string; 4124 4125 getFullyQualifiedName(symbol: Symbol): string; 4126 getAugmentedPropertiesOfType(type: Type): Symbol[]; 4127 4128 getRootSymbols(symbol: Symbol): readonly Symbol[]; 4129 getSymbolOfExpando(node: Node, allowDeclaration: boolean): Symbol | undefined; 4130 getContextualType(node: Expression): Type | undefined; 4131 /* @internal */ getContextualType(node: Expression, contextFlags?: ContextFlags): Type | undefined; // eslint-disable-line @typescript-eslint/unified-signatures 4132 /* @internal */ getContextualTypeForObjectLiteralElement(element: ObjectLiteralElementLike): Type | undefined; 4133 /* @internal */ getContextualTypeForArgumentAtIndex(call: CallLikeExpression, argIndex: number): Type | undefined; 4134 /* @internal */ getContextualTypeForJsxAttribute(attribute: JsxAttribute | JsxSpreadAttribute): Type | undefined; 4135 /* @internal */ isContextSensitive(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike): boolean; 4136 4137 /** 4138 * returns unknownSignature in the case of an error. 4139 * returns undefined if the node is not valid. 4140 * @param argumentCount Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See `signatureHelp.ts`. 4141 */ 4142 getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; 4143 tryGetResolvedSignatureWithoutCheck(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; 4144 /* @internal */ getResolvedSignatureForSignatureHelp(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; 4145 /* @internal */ getExpandedParameters(sig: Signature): readonly (readonly Symbol[])[]; 4146 /* @internal */ hasEffectiveRestParameter(sig: Signature): boolean; 4147 getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined; 4148 isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; 4149 isUndefinedSymbol(symbol: Symbol): boolean; 4150 isArgumentsSymbol(symbol: Symbol): boolean; 4151 isUnknownSymbol(symbol: Symbol): boolean; 4152 /* @internal */ getMergedSymbol(symbol: Symbol): Symbol; 4153 4154 getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined; 4155 isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName | ImportTypeNode, propertyName: string): boolean; 4156 /** Exclude accesses to private properties or methods with a `this` parameter that `type` doesn't satisfy. */ 4157 /* @internal */ isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode | QualifiedName, type: Type, property: Symbol): boolean; 4158 /** Follow all aliases to get the original symbol. */ 4159 getAliasedSymbol(symbol: Symbol): Symbol; 4160 /** Follow a *single* alias to get the immediately aliased symbol. */ 4161 /* @internal */ getImmediateAliasedSymbol(symbol: Symbol): Symbol | undefined; 4162 getExportsOfModule(moduleSymbol: Symbol): Symbol[]; 4163 /** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */ 4164 /* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[]; 4165 getJsxIntrinsicTagNamesAt(location: Node): Symbol[]; 4166 isOptionalParameter(node: ParameterDeclaration): boolean; 4167 getAmbientModules(): Symbol[]; 4168 4169 tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; 4170 /** 4171 * Unlike `tryGetMemberInModuleExports`, this includes properties of an `export =` value. 4172 * Does *not* return properties of primitive types. 4173 */ 4174 /* @internal */ tryGetMemberInModuleExportsAndProperties(memberName: string, moduleSymbol: Symbol): Symbol | undefined; 4175 getApparentType(type: Type): Type; 4176 /* @internal */ getSuggestedSymbolForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type): Symbol | undefined; 4177 /* @internal */ getSuggestedSymbolForNonexistentJSXAttribute(name: Identifier | string, containingType: Type): Symbol | undefined; 4178 /* @internal */ getSuggestionForNonexistentProperty(name: Identifier | PrivateIdentifier | string, containingType: Type): string | undefined; 4179 /* @internal */ getSuggestedSymbolForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): Symbol | undefined; 4180 /* @internal */ getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; 4181 /* @internal */ getSuggestedSymbolForNonexistentModule(node: Identifier, target: Symbol): Symbol | undefined; 4182 /* @internal */ getSuggestionForNonexistentExport(node: Identifier, target: Symbol): string | undefined; 4183 getBaseConstraintOfType(type: Type): Type | undefined; 4184 getDefaultFromTypeParameter(type: Type): Type | undefined; 4185 4186 /* @internal */ getAnyType(): Type; 4187 /* @internal */ getStringType(): Type; 4188 /* @internal */ getNumberType(): Type; 4189 /* @internal */ getBooleanType(): Type; 4190 /* @internal */ getFalseType(fresh?: boolean): Type; 4191 /* @internal */ getTrueType(fresh?: boolean): Type; 4192 /* @internal */ getVoidType(): Type; 4193 /* @internal */ getUndefinedType(): Type; 4194 /* @internal */ getNullType(): Type; 4195 /* @internal */ getESSymbolType(): Type; 4196 /* @internal */ getNeverType(): Type; 4197 /* @internal */ getOptionalType(): Type; 4198 /* @internal */ getUnionType(types: Type[], subtypeReduction?: UnionReduction): Type; 4199 /* @internal */ createArrayType(elementType: Type): Type; 4200 /* @internal */ getElementTypeOfArrayType(arrayType: Type): Type | undefined; 4201 /* @internal */ createPromiseType(type: Type): Type; 4202 4203 /* @internal */ isTypeAssignableTo(source: Type, target: Type): boolean; 4204 /* @internal */ createAnonymousType(symbol: Symbol | undefined, members: SymbolTable, callSignatures: Signature[], constructSignatures: Signature[], stringIndexInfo: IndexInfo | undefined, numberIndexInfo: IndexInfo | undefined): Type; 4205 /* @internal */ createSignature( 4206 declaration: SignatureDeclaration, 4207 typeParameters: readonly TypeParameter[] | undefined, 4208 thisParameter: Symbol | undefined, 4209 parameters: readonly Symbol[], 4210 resolvedReturnType: Type, 4211 typePredicate: TypePredicate | undefined, 4212 minArgumentCount: number, 4213 flags: SignatureFlags 4214 ): Signature; 4215 /* @internal */ createSymbol(flags: SymbolFlags, name: __String): TransientSymbol; 4216 /* @internal */ createIndexInfo(type: Type, isReadonly: boolean, declaration?: SignatureDeclaration): IndexInfo; 4217 /* @internal */ isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; 4218 /* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined; 4219 4220 /* @internal */ getSymbolWalker(accept?: (symbol: Symbol) => boolean): SymbolWalker; 4221 4222 // Should not be called directly. Should only be accessed through the Program instance. 4223 /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; 4224 /* @internal */ getGlobalDiagnostics(): Diagnostic[]; 4225 /* @internal */ getEmitResolver(sourceFile?: SourceFile, cancellationToken?: CancellationToken): EmitResolver; 4226 4227 /* @internal */ getTypeCatalog(): readonly Type[]; 4228 4229 /* @internal */ getNodeCount(): number; 4230 /* @internal */ getIdentifierCount(): number; 4231 /* @internal */ getSymbolCount(): number; 4232 /* @internal */ getTypeCount(): number; 4233 /* @internal */ getInstantiationCount(): number; 4234 /* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number }; 4235 /* @internal */ getRecursionIdentity(type: Type): object | undefined; 4236 4237 /* @internal */ isArrayType(type: Type): boolean; 4238 /* @internal */ isTupleType(type: Type): boolean; 4239 /* @internal */ isArrayLikeType(type: Type): boolean; 4240 4241 /** 4242 * True if `contextualType` should not be considered for completions because 4243 * e.g. it specifies `kind: "a"` and obj has `kind: "b"`. 4244 */ 4245 /* @internal */ isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean; 4246 /** 4247 * For a union, will include a property if it's defined in *any* of the member types. 4248 * So for `{ a } | { b }`, this will include both `a` and `b`. 4249 * Does not include properties of primitive types. 4250 */ 4251 /* @internal */ getAllPossiblePropertiesOfTypes(type: readonly Type[]): Symbol[]; 4252 /* @internal */ resolveName(name: string, location: Node | undefined, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined; 4253 /* @internal */ getJsxNamespace(location?: Node): string; 4254 /* @internal */ getJsxFragmentFactory(location: Node): string | undefined; 4255 4256 /** 4257 * Note that this will return undefined in the following case: 4258 * // a.ts 4259 * export namespace N { export class C { } } 4260 * // b.ts 4261 * <<enclosingDeclaration>> 4262 * Where `C` is the symbol we're looking for. 4263 * This should be called in a loop climbing parents of the symbol, so we'll get `N`. 4264 */ 4265 /* @internal */ getAccessibleSymbolChain(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags, useOnlyExternalAliasing: boolean): Symbol[] | undefined; 4266 /* @internal */ getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined; 4267 /* @internal */ resolveExternalModuleName(moduleSpecifier: Expression): Symbol | undefined; 4268 /** 4269 * An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, 4270 * and an external module with no 'export =' declaration resolves to the module itself. 4271 */ 4272 /* @internal */ resolveExternalModuleSymbol(symbol: Symbol): Symbol; 4273 /** @param node A location where we might consider accessing `this`. Not necessarily a ThisExpression. */ 4274 /* @internal */ tryGetThisTypeAt(node: Node, includeGlobalThis?: boolean): Type | undefined; 4275 /* @internal */ getTypeArgumentConstraint(node: TypeNode): Type | undefined; 4276 4277 /** 4278 * Does *not* get *all* suggestion diagnostics, just the ones that were convenient to report in the checker. 4279 * Others are added in computeSuggestionDiagnostics. 4280 */ 4281 /* @internal */ getSuggestionDiagnostics(file: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; 4282 4283 /** 4284 * Depending on the operation performed, it may be appropriate to throw away the checker 4285 * if the cancellation token is triggered. Typically, if it is used for error checking 4286 * and the operation is cancelled, then it should be discarded, otherwise it is safe to keep. 4287 */ 4288 runWithCancellationToken<T>(token: CancellationToken, cb: (checker: TypeChecker) => T): T; 4289 4290 /* @internal */ getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol: Symbol): readonly TypeParameter[] | undefined; 4291 /* @internal */ isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; 4292 } 4293 4294 /* @internal */ 4295 export const enum UnionReduction { 4296 None = 0, 4297 Literal, 4298 Subtype, 4299 } 4300 4301 /* @internal */ 4302 export const enum ContextFlags { 4303 None = 0, 4304 Signature = 1 << 0, // Obtaining contextual signature 4305 NoConstraints = 1 << 1, // Don't obtain type variable constraints 4306 Completions = 1 << 2, // Ignore inference to current node and parent nodes out to the containing call for completions 4307 SkipBindingPatterns = 1 << 3, // Ignore contextual types applied by binding patterns 4308 } 4309 4310 // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! 4311 export const enum NodeBuilderFlags { 4312 None = 0, 4313 // Options 4314 NoTruncation = 1 << 0, // Don't truncate result 4315 WriteArrayAsGenericType = 1 << 1, // Write Array<T> instead T[] 4316 GenerateNamesForShadowedTypeParams = 1 << 2, // When a type parameter T is shadowing another T, generate a name for it so it can still be referenced 4317 UseStructuralFallback = 1 << 3, // When an alias cannot be named by its symbol, rather than report an error, fallback to a structural printout if possible 4318 ForbidIndexedAccessSymbolReferences = 1 << 4, // Forbid references like `I["a"]["b"]` - print `typeof I.a<x>.b<y>` instead 4319 WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature 4320 UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type) 4321 UseOnlyExternalAliasing = 1 << 7, // Only use external aliases for a symbol 4322 SuppressAnyReturnType = 1 << 8, // If the return type is any-like and can be elided, don't offer a return type. 4323 WriteTypeParametersInQualifiedName = 1 << 9, 4324 MultilineObjectLiterals = 1 << 10, // Always write object literals across multiple lines 4325 WriteClassExpressionAsTypeLiteral = 1 << 11, // Write class {} as { new(): {} } - used for mixin declaration emit 4326 UseTypeOfFunction = 1 << 12, // Build using typeof instead of function type literal 4327 OmitParameterModifiers = 1 << 13, // Omit modifiers on parameters 4328 UseAliasDefinedOutsideCurrentScope = 1 << 14, // Allow non-visible aliases 4329 UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type 4330 NoTypeReduction = 1 << 29, // Don't call getReducedType 4331 NoUndefinedOptionalParameterType = 1 << 30, // Do not add undefined to optional parameter type 4332 4333 // Error handling 4334 AllowThisInObjectLiteral = 1 << 15, 4335 AllowQualifedNameInPlaceOfIdentifier = 1 << 16, 4336 AllowAnonymousIdentifier = 1 << 17, 4337 AllowEmptyUnionOrIntersection = 1 << 18, 4338 AllowEmptyTuple = 1 << 19, 4339 AllowUniqueESSymbolType = 1 << 20, 4340 AllowEmptyIndexInfoType = 1 << 21, 4341 4342 // Errors (cont.) 4343 AllowNodeModulesRelativePaths = 1 << 26, 4344 /* @internal */ DoNotIncludeSymbolChain = 1 << 27, // Skip looking up and printing an accessible symbol chain 4345 4346 IgnoreErrors = AllowThisInObjectLiteral | AllowQualifedNameInPlaceOfIdentifier | AllowAnonymousIdentifier | AllowEmptyUnionOrIntersection | AllowEmptyTuple | AllowEmptyIndexInfoType | AllowNodeModulesRelativePaths, 4347 4348 // State 4349 InObjectTypeLiteral = 1 << 22, 4350 InTypeAlias = 1 << 23, // Writing type in type alias declaration 4351 InInitialEntityName = 1 << 24, // Set when writing the LHS of an entity name or entity name expression 4352 InReverseMappedType = 1 << 25, 4353 } 4354 4355 // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment 4356 export const enum TypeFormatFlags { 4357 None = 0, 4358 NoTruncation = 1 << 0, // Don't truncate typeToString result 4359 WriteArrayAsGenericType = 1 << 1, // Write Array<T> instead T[] 4360 // hole because there's a hole in node builder flags 4361 UseStructuralFallback = 1 << 3, // When an alias cannot be named by its symbol, rather than report an error, fallback to a structural printout if possible 4362 // hole because there's a hole in node builder flags 4363 WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature 4364 UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type) 4365 // hole because `UseOnlyExternalAliasing` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` instead 4366 SuppressAnyReturnType = 1 << 8, // If the return type is any-like, don't offer a return type. 4367 // hole because `WriteTypeParametersInQualifiedName` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` for this instead 4368 MultilineObjectLiterals = 1 << 10, // Always print object literals across multiple lines (only used to map into node builder flags) 4369 WriteClassExpressionAsTypeLiteral = 1 << 11, // Write a type literal instead of (Anonymous class) 4370 UseTypeOfFunction = 1 << 12, // Write typeof instead of function type literal 4371 OmitParameterModifiers = 1 << 13, // Omit modifiers on parameters 4372 4373 UseAliasDefinedOutsideCurrentScope = 1 << 14, // For a `type T = ... ` defined in a different file, write `T` instead of its value, even though `T` can't be accessed in the current scope. 4374 UseSingleQuotesForStringLiteralType = 1 << 28, // Use single quotes for string literal type 4375 NoTypeReduction = 1 << 29, // Don't call getReducedType 4376 4377 // Error Handling 4378 AllowUniqueESSymbolType = 1 << 20, // This is bit 20 to align with the same bit in `NodeBuilderFlags` 4379 4380 // TypeFormatFlags exclusive 4381 AddUndefined = 1 << 17, // Add undefined to types of initialized, non-optional parameters 4382 WriteArrowStyleSignature = 1 << 18, // Write arrow style signature 4383 4384 // State 4385 InArrayType = 1 << 19, // Writing an array element type 4386 InElementType = 1 << 21, // Writing an array or union element type 4387 InFirstTypeArgument = 1 << 22, // Writing first type argument of the instantiated type 4388 InTypeAlias = 1 << 23, // Writing type in type alias declaration 4389 4390 /** @deprecated */ WriteOwnNameForAnyLike = 0, // Does nothing 4391 4392 NodeBuilderFlagsMask = NoTruncation | WriteArrayAsGenericType | UseStructuralFallback | WriteTypeArgumentsOfSignature | 4393 UseFullyQualifiedType | SuppressAnyReturnType | MultilineObjectLiterals | WriteClassExpressionAsTypeLiteral | 4394 UseTypeOfFunction | OmitParameterModifiers | UseAliasDefinedOutsideCurrentScope | AllowUniqueESSymbolType | InTypeAlias | 4395 UseSingleQuotesForStringLiteralType | NoTypeReduction, 4396 } 4397 4398 export const enum SymbolFormatFlags { 4399 None = 0x00000000, 4400 4401 // Write symbols's type argument if it is instantiated symbol 4402 // eg. class C<T> { p: T } <-- Show p as C<T>.p here 4403 // var a: C<number>; 4404 // var p = a.p; <--- Here p is property of C<number> so show it as C<number>.p instead of just C.p 4405 WriteTypeParametersOrArguments = 0x00000001, 4406 4407 // Use only external alias information to get the symbol name in the given context 4408 // eg. module m { export class c { } } import x = m.c; 4409 // When this flag is specified m.c will be used to refer to the class instead of alias symbol x 4410 UseOnlyExternalAliasing = 0x00000002, 4411 4412 // Build symbol name using any nodes needed, instead of just components of an entity name 4413 AllowAnyNodeKind = 0x00000004, 4414 4415 // Prefer aliases which are not directly visible 4416 UseAliasDefinedOutsideCurrentScope = 0x00000008, 4417 4418 // Skip building an accessible symbol chain 4419 /* @internal */ DoNotIncludeSymbolChain = 0x00000010, 4420 } 4421 4422 /* @internal */ 4423 export interface SymbolWalker { 4424 /** Note: Return values are not ordered. */ 4425 walkType(root: Type): { visitedTypes: readonly Type[], visitedSymbols: readonly Symbol[] }; 4426 /** Note: Return values are not ordered. */ 4427 walkSymbol(root: Symbol): { visitedTypes: readonly Type[], visitedSymbols: readonly Symbol[] }; 4428 } 4429 4430 // This was previously deprecated in our public API, but is still used internally 4431 interface SymbolWriter extends SymbolTracker { 4432 writeKeyword(text: string): void; 4433 writeOperator(text: string): void; 4434 writePunctuation(text: string): void; 4435 writeSpace(text: string): void; 4436 writeStringLiteral(text: string): void; 4437 writeParameter(text: string): void; 4438 writeProperty(text: string): void; 4439 writeSymbol(text: string, symbol: Symbol): void; 4440 writeLine(force?: boolean): void; 4441 increaseIndent(): void; 4442 decreaseIndent(): void; 4443 clear(): void; 4444 } 4445 4446 /* @internal */ 4447 export const enum SymbolAccessibility { 4448 Accessible, 4449 NotAccessible, 4450 CannotBeNamed 4451 } 4452 4453 /* @internal */ 4454 export const enum SyntheticSymbolKind { 4455 UnionOrIntersection, 4456 Spread 4457 } 4458 4459 export const enum TypePredicateKind { 4460 This, 4461 Identifier, 4462 AssertsThis, 4463 AssertsIdentifier 4464 } 4465 4466 export interface TypePredicateBase { 4467 kind: TypePredicateKind; 4468 type: Type | undefined; 4469 } 4470 4471 export interface ThisTypePredicate extends TypePredicateBase { 4472 kind: TypePredicateKind.This; 4473 parameterName: undefined; 4474 parameterIndex: undefined; 4475 type: Type; 4476 } 4477 4478 export interface IdentifierTypePredicate extends TypePredicateBase { 4479 kind: TypePredicateKind.Identifier; 4480 parameterName: string; 4481 parameterIndex: number; 4482 type: Type; 4483 } 4484 4485 export interface AssertsThisTypePredicate extends TypePredicateBase { 4486 kind: TypePredicateKind.AssertsThis; 4487 parameterName: undefined; 4488 parameterIndex: undefined; 4489 type: Type | undefined; 4490 } 4491 4492 export interface AssertsIdentifierTypePredicate extends TypePredicateBase { 4493 kind: TypePredicateKind.AssertsIdentifier; 4494 parameterName: string; 4495 parameterIndex: number; 4496 type: Type | undefined; 4497 } 4498 4499 export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; 4500 4501 /* @internal */ 4502 export type AnyImportSyntax = ImportDeclaration | ImportEqualsDeclaration; 4503 4504 /* @internal */ 4505 export type AnyImportOrRequire = AnyImportSyntax | RequireVariableDeclaration; 4506 4507 /* @internal */ 4508 export type AnyImportOrRequireStatement = AnyImportSyntax | RequireVariableStatement; 4509 4510 4511 /* @internal */ 4512 export type AnyImportOrReExport = AnyImportSyntax | ExportDeclaration; 4513 4514 /* @internal */ 4515 export interface ValidImportTypeNode extends ImportTypeNode { 4516 argument: LiteralTypeNode & { literal: StringLiteral }; 4517 } 4518 4519 /* @internal */ 4520 export type AnyValidImportOrReExport = 4521 | (ImportDeclaration | ExportDeclaration) & { moduleSpecifier: StringLiteral } 4522 | ImportEqualsDeclaration & { moduleReference: ExternalModuleReference & { expression: StringLiteral } } 4523 | RequireOrImportCall 4524 | ValidImportTypeNode; 4525 4526 /* @internal */ 4527 export type RequireOrImportCall = CallExpression & { expression: Identifier, arguments: [StringLiteralLike] }; 4528 4529 /* @internal */ 4530 export interface RequireVariableDeclaration extends VariableDeclaration { 4531 readonly initializer: RequireOrImportCall; 4532 } 4533 4534 /* @internal */ 4535 export interface RequireVariableStatement extends VariableStatement { 4536 readonly declarationList: RequireVariableDeclarationList; 4537 } 4538 4539 /* @internal */ 4540 export interface RequireVariableDeclarationList extends VariableDeclarationList { 4541 readonly declarations: NodeArray<RequireVariableDeclaration>; 4542 } 4543 4544 /* @internal */ 4545 export type LateVisibilityPaintedStatement = 4546 | AnyImportSyntax 4547 | VariableStatement 4548 | ClassDeclaration 4549 | FunctionDeclaration 4550 | ModuleDeclaration 4551 | TypeAliasDeclaration 4552 | InterfaceDeclaration 4553 | EnumDeclaration 4554 | StructDeclaration; 4555 4556 /* @internal */ 4557 export interface SymbolVisibilityResult { 4558 accessibility: SymbolAccessibility; 4559 aliasesToMakeVisible?: LateVisibilityPaintedStatement[]; // aliases that need to have this symbol visible 4560 errorSymbolName?: string; // Optional symbol name that results in error 4561 errorNode?: Node; // optional node that results in error 4562 } 4563 4564 /* @internal */ 4565 export interface SymbolAccessibilityResult extends SymbolVisibilityResult { 4566 errorModuleName?: string; // If the symbol is not visible from module, module's name 4567 } 4568 4569 /* @internal */ 4570 export interface AllAccessorDeclarations { 4571 firstAccessor: AccessorDeclaration; 4572 secondAccessor: AccessorDeclaration | undefined; 4573 getAccessor: GetAccessorDeclaration | undefined; 4574 setAccessor: SetAccessorDeclaration | undefined; 4575 } 4576 4577 /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ 4578 /* @internal */ 4579 export enum TypeReferenceSerializationKind { 4580 // The TypeReferenceNode could not be resolved. 4581 // The type name should be emitted using a safe fallback. 4582 Unknown, 4583 4584 // The TypeReferenceNode resolves to a type with a constructor 4585 // function that can be reached at runtime (e.g. a `class` 4586 // declaration or a `var` declaration for the static side 4587 // of a type, such as the global `Promise` type in lib.d.ts). 4588 TypeWithConstructSignatureAndValue, 4589 4590 // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. 4591 VoidNullableOrNeverType, 4592 4593 // The TypeReferenceNode resolves to a Number-like type. 4594 NumberLikeType, 4595 4596 // The TypeReferenceNode resolves to a BigInt-like type. 4597 BigIntLikeType, 4598 4599 // The TypeReferenceNode resolves to a String-like type. 4600 StringLikeType, 4601 4602 // The TypeReferenceNode resolves to a Boolean-like type. 4603 BooleanType, 4604 4605 // The TypeReferenceNode resolves to an Array-like type. 4606 ArrayLikeType, 4607 4608 // The TypeReferenceNode resolves to the ESSymbol type. 4609 ESSymbolType, 4610 4611 // The TypeReferenceNode resolved to the global Promise constructor symbol. 4612 Promise, 4613 4614 // The TypeReferenceNode resolves to a Function type or a type with call signatures. 4615 TypeWithCallSignature, 4616 4617 // The TypeReferenceNode resolves to any other type. 4618 ObjectType, 4619 } 4620 4621 /* @internal */ 4622 export interface EmitResolver { 4623 hasGlobalName(name: string): boolean; 4624 getReferencedExportContainer(node: Identifier, prefixLocals?: boolean): SourceFile | ModuleDeclaration | EnumDeclaration | undefined; 4625 getReferencedImportDeclaration(node: Identifier): Declaration | undefined; 4626 getReferencedDeclarationWithCollidingName(node: Identifier): Declaration | undefined; 4627 isDeclarationWithCollidingName(node: Declaration): boolean; 4628 isValueAliasDeclaration(node: Node): boolean; 4629 isReferencedAliasDeclaration(node: Node, checkChildren?: boolean): boolean; 4630 isReferenced(node: Node): boolean; 4631 isTopLevelValueImportEqualsWithEntityName(node: ImportEqualsDeclaration): boolean; 4632 getNodeCheckFlags(node: Node): NodeCheckFlags; 4633 isDeclarationVisible(node: Declaration | AnyImportSyntax): boolean; 4634 isLateBound(node: Declaration): node is LateBoundDeclaration; 4635 collectLinkedAliases(node: Identifier, setVisibility?: boolean): Node[] | undefined; 4636 isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; 4637 isRequiredInitializedParameter(node: ParameterDeclaration): boolean; 4638 isOptionalUninitializedParameterProperty(node: ParameterDeclaration): boolean; 4639 isExpandoFunctionDeclaration(node: FunctionDeclaration): boolean; 4640 getPropertiesOfContainerFunction(node: Declaration): Symbol[]; 4641 createTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration | PropertyAccessExpression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker, addUndefined?: boolean): TypeNode | undefined; 4642 createReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined; 4643 createTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: NodeBuilderFlags, tracker: SymbolTracker): TypeNode | undefined; 4644 createLiteralConstValue(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration, tracker: SymbolTracker): Expression; 4645 isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags | undefined, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; 4646 isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; 4647 // Returns the constant value this property access resolves to, or 'undefined' for a non-constant 4648 getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined; 4649 getReferencedValueDeclaration(reference: Identifier): Declaration | undefined; 4650 getTypeReferenceSerializationKind(typeName: EntityName, location?: Node): TypeReferenceSerializationKind; 4651 isOptionalParameter(node: ParameterDeclaration): boolean; 4652 moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; 4653 isArgumentsLocalBinding(node: Identifier): boolean; 4654 getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode | ImportCall): SourceFile | undefined; 4655 getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[] | undefined; 4656 getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[] | undefined; 4657 isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; 4658 getJsxFactoryEntity(location?: Node): EntityName | undefined; 4659 getJsxFragmentFactoryEntity(location?: Node): EntityName | undefined; 4660 getAllAccessorDeclarations(declaration: AccessorDeclaration): AllAccessorDeclarations; 4661 getSymbolOfExternalModuleSpecifier(node: StringLiteralLike): Symbol | undefined; 4662 isBindingCapturedByNode(node: Node, decl: VariableDeclaration | BindingElement): boolean; 4663 getDeclarationStatementsForSourceFile(node: SourceFile, flags: NodeBuilderFlags, tracker: SymbolTracker, bundled?: boolean): Statement[] | undefined; 4664 isImportRequiredByAugmentation(decl: ImportDeclaration): boolean; 4665 } 4666 4667 export const enum SymbolFlags { 4668 None = 0, 4669 FunctionScopedVariable = 1 << 0, // Variable (var) or parameter 4670 BlockScopedVariable = 1 << 1, // A block-scoped variable (let or const) 4671 Property = 1 << 2, // Property or enum member 4672 EnumMember = 1 << 3, // Enum member 4673 Function = 1 << 4, // Function 4674 Class = 1 << 5, // Class 4675 Interface = 1 << 6, // Interface 4676 ConstEnum = 1 << 7, // Const enum 4677 RegularEnum = 1 << 8, // Enum 4678 ValueModule = 1 << 9, // Instantiated module 4679 NamespaceModule = 1 << 10, // Uninstantiated module 4680 TypeLiteral = 1 << 11, // Type Literal or mapped type 4681 ObjectLiteral = 1 << 12, // Object Literal 4682 Method = 1 << 13, // Method 4683 Constructor = 1 << 14, // Constructor 4684 GetAccessor = 1 << 15, // Get accessor 4685 SetAccessor = 1 << 16, // Set accessor 4686 Signature = 1 << 17, // Call, construct, or index signature 4687 TypeParameter = 1 << 18, // Type parameter 4688 TypeAlias = 1 << 19, // Type alias 4689 ExportValue = 1 << 20, // Exported value marker (see comment in declareModuleMember in binder) 4690 Alias = 1 << 21, // An alias for another symbol (see comment in isAliasSymbolDeclaration in checker) 4691 Prototype = 1 << 22, // Prototype property (no source representation) 4692 ExportStar = 1 << 23, // Export * declaration 4693 Optional = 1 << 24, // Optional property 4694 Transient = 1 << 25, // Transient symbol (created during type check) 4695 Assignment = 1 << 26, // Assignment treated as declaration (eg `this.prop = 1`) 4696 ModuleExports = 1 << 27, // Symbol for CommonJS `module` of `module.exports` 4697 /* @internal */ 4698 All = FunctionScopedVariable | BlockScopedVariable | Property | EnumMember | Function | Class | Interface | ConstEnum | RegularEnum | ValueModule | NamespaceModule | TypeLiteral 4699 | ObjectLiteral | Method | Constructor | GetAccessor | SetAccessor | Signature | TypeParameter | TypeAlias | ExportValue | Alias | Prototype | ExportStar | Optional | Transient, 4700 4701 Enum = RegularEnum | ConstEnum, 4702 Variable = FunctionScopedVariable | BlockScopedVariable, 4703 Value = Variable | Property | EnumMember | ObjectLiteral | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor, 4704 Type = Class | Interface | Enum | EnumMember | TypeLiteral | TypeParameter | TypeAlias, 4705 Namespace = ValueModule | NamespaceModule | Enum, 4706 Module = ValueModule | NamespaceModule, 4707 Accessor = GetAccessor | SetAccessor, 4708 4709 // Variables can be redeclared, but can not redeclare a block-scoped declaration with the 4710 // same name, or any other value that is not a variable, e.g. ValueModule or Class 4711 FunctionScopedVariableExcludes = Value & ~FunctionScopedVariable, 4712 4713 // Block-scoped declarations are not allowed to be re-declared 4714 // they can not merge with anything in the value space 4715 BlockScopedVariableExcludes = Value, 4716 4717 ParameterExcludes = Value, 4718 PropertyExcludes = None, 4719 EnumMemberExcludes = Value | Type, 4720 FunctionExcludes = Value & ~(Function | ValueModule | Class), 4721 ClassExcludes = (Value | Type) & ~(ValueModule | Interface | Function), // class-interface mergability done in checker.ts 4722 InterfaceExcludes = Type & ~(Interface | Class), 4723 RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules 4724 ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums 4725 ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), 4726 NamespaceModuleExcludes = 0, 4727 MethodExcludes = Value & ~Method, 4728 GetAccessorExcludes = Value & ~SetAccessor, 4729 SetAccessorExcludes = Value & ~GetAccessor, 4730 TypeParameterExcludes = Type & ~TypeParameter, 4731 TypeAliasExcludes = Type, 4732 AliasExcludes = Alias, 4733 4734 ModuleMember = Variable | Function | Class | Interface | Enum | Module | TypeAlias | Alias, 4735 4736 ExportHasLocal = Function | Class | Enum | ValueModule, 4737 4738 BlockScoped = BlockScopedVariable | Class | Enum, 4739 4740 PropertyOrAccessor = Property | Accessor, 4741 4742 ClassMember = Method | Accessor | Property, 4743 4744 /* @internal */ 4745 ExportSupportsDefaultModifier = Class | Function | Interface, 4746 4747 /* @internal */ 4748 ExportDoesNotSupportDefaultModifier = ~ExportSupportsDefaultModifier, 4749 4750 /* @internal */ 4751 // The set of things we consider semantically classifiable. Used to speed up the LS during 4752 // classification. 4753 Classifiable = Class | Enum | TypeAlias | Interface | TypeParameter | Module | Alias, 4754 4755 /* @internal */ 4756 LateBindingContainer = Class | Interface | TypeLiteral | ObjectLiteral | Function, 4757 } 4758 4759 /* @internal */ 4760 export type SymbolId = number; 4761 4762 export interface Symbol { 4763 flags: SymbolFlags; // Symbol flags 4764 escapedName: __String; // Name of symbol 4765 declarations: Declaration[]; // Declarations associated with this symbol 4766 valueDeclaration: Declaration; // First value declaration of the symbol 4767 members?: SymbolTable; // Class, interface or object literal instance members 4768 exports?: SymbolTable; // Module exports 4769 globalExports?: SymbolTable; // Conditional global UMD exports 4770 /* @internal */ id?: SymbolId; // Unique id (used to look up SymbolLinks) 4771 /* @internal */ mergeId?: number; // Merge id (used to look up merged symbol) 4772 /* @internal */ parent?: Symbol; // Parent symbol 4773 exportSymbol?: Symbol; // Exported symbol associated with this symbol 4774 /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums 4775 /* @internal */ isReferenced?: SymbolFlags; // True if the symbol is referenced elsewhere. Keeps track of the meaning of a reference in case a symbol is both a type parameter and parameter. 4776 /* @internal */ isReplaceableByMethod?: boolean; // Can this Javascript class property be replaced by a method symbol? 4777 /* @internal */ isAssigned?: boolean; // True if the symbol is a parameter with assignments 4778 /* @internal */ assignmentDeclarationMembers?: ESMap<number, Declaration>; // detected late-bound assignment declarations associated with the symbol 4779 } 4780 4781 /* @internal */ 4782 export interface SymbolLinks { 4783 immediateTarget?: Symbol; // Immediate target of an alias. May be another alias. Do not access directly, use `checker.getImmediateAliasedSymbol` instead. 4784 target?: Symbol; // Resolved (non-alias) target of an alias 4785 type?: Type; // Type of value symbol 4786 nameType?: Type; // Type associated with a late-bound symbol 4787 uniqueESSymbolType?: Type; // UniqueESSymbol type for a symbol 4788 declaredType?: Type; // Type of class, interface, enum, type alias, or type parameter 4789 typeParameters?: TypeParameter[]; // Type parameters of type alias (undefined if non-generic) 4790 outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type 4791 instantiations?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic) 4792 aliasSymbol?: Symbol; // Alias associated with generic type alias instantiation 4793 aliasTypeArguments?: readonly Type[] // Alias type arguments (if any) 4794 inferredClassSymbol?: ESMap<SymbolId, TransientSymbol>; // Symbol of an inferred ES5 constructor function 4795 mapper?: TypeMapper; // Type mapper for instantiation alias 4796 referenced?: boolean; // True if alias symbol has been referenced as a value that can be emitted 4797 constEnumReferenced?: boolean; // True if alias symbol resolves to a const enum and is referenced as a value ('referenced' will be false) 4798 containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property 4799 leftSpread?: Symbol; // Left source for synthetic spread property 4800 rightSpread?: Symbol; // Right source for synthetic spread property 4801 syntheticOrigin?: Symbol; // For a property on a mapped or spread type, points back to the original property 4802 isDiscriminantProperty?: boolean; // True if discriminant synthetic property 4803 resolvedExports?: SymbolTable; // Resolved exports of module or combined early- and late-bound static members of a class. 4804 resolvedMembers?: SymbolTable; // Combined early- and late-bound members of a symbol 4805 exportsChecked?: boolean; // True if exports of external module have been checked 4806 typeParametersChecked?: boolean; // True if type parameters of merged class and interface declarations have been checked. 4807 isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration 4808 bindingElement?: BindingElement; // Binding element associated with property symbol 4809 exportsSomeValue?: boolean; // True if module exports some value (not just types) 4810 enumKind?: EnumKind; // Enum declaration classification 4811 originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is marked as uncallable but had call signatures in `resolveESModuleSymbol` 4812 lateSymbol?: Symbol; // Late-bound symbol for a computed property 4813 specifierCache?: ESMap<string, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings 4814 extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in 4815 extendedContainersByFile?: ESMap<NodeId, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in 4816 variances?: VarianceFlags[]; // Alias symbol type argument variance cache 4817 deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type 4818 deferralParent?: Type; // Source union/intersection of a deferred type 4819 cjsExportMerged?: Symbol; // Version of the symbol with all non export= exports merged with the export= target 4820 typeOnlyDeclaration?: TypeOnlyCompatibleAliasDeclaration | false; // First resolved alias declaration that makes the symbol only usable in type constructs 4821 isConstructorDeclaredProperty?: boolean; // Property declared through 'this.x = ...' assignment in constructor 4822 tupleLabelDeclaration?: NamedTupleMember | ParameterDeclaration; // Declaration associated with the tuple's label 4823 } 4824 4825 /* @internal */ 4826 export const enum EnumKind { 4827 Numeric, // Numeric enum (each member has a TypeFlags.Enum type) 4828 Literal // Literal enum (each member has a TypeFlags.EnumLiteral type) 4829 } 4830 4831 /* @internal */ 4832 export const enum CheckFlags { 4833 Instantiated = 1 << 0, // Instantiated symbol 4834 SyntheticProperty = 1 << 1, // Property in union or intersection type 4835 SyntheticMethod = 1 << 2, // Method in union or intersection type 4836 Readonly = 1 << 3, // Readonly transient symbol 4837 ReadPartial = 1 << 4, // Synthetic property present in some but not all constituents 4838 WritePartial = 1 << 5, // Synthetic property present in some but only satisfied by an index signature in others 4839 HasNonUniformType = 1 << 6, // Synthetic property with non-uniform type in constituents 4840 HasLiteralType = 1 << 7, // Synthetic property with at least one literal type in constituents 4841 ContainsPublic = 1 << 8, // Synthetic property with public constituent(s) 4842 ContainsProtected = 1 << 9, // Synthetic property with protected constituent(s) 4843 ContainsPrivate = 1 << 10, // Synthetic property with private constituent(s) 4844 ContainsStatic = 1 << 11, // Synthetic property with static constituent(s) 4845 Late = 1 << 12, // Late-bound symbol for a computed property with a dynamic name 4846 ReverseMapped = 1 << 13, // Property of reverse-inferred homomorphic mapped type 4847 OptionalParameter = 1 << 14, // Optional parameter 4848 RestParameter = 1 << 15, // Rest parameter 4849 DeferredType = 1 << 16, // Calculation of the type of this symbol is deferred due to processing costs, should be fetched with `getTypeOfSymbolWithDeferredType` 4850 HasNeverType = 1 << 17, // Synthetic property with at least one never type in constituents 4851 Mapped = 1 << 18, // Property of mapped type 4852 StripOptional = 1 << 19, // Strip optionality in mapped property 4853 Synthetic = SyntheticProperty | SyntheticMethod, 4854 Discriminant = HasNonUniformType | HasLiteralType, 4855 Partial = ReadPartial | WritePartial 4856 } 4857 4858 /* @internal */ 4859 export interface TransientSymbol extends Symbol, SymbolLinks { 4860 checkFlags: CheckFlags; 4861 } 4862 4863 /* @internal */ 4864 export interface MappedSymbol extends TransientSymbol { 4865 mappedType: MappedType; 4866 keyType: Type; 4867 } 4868 4869 /* @internal */ 4870 export interface ReverseMappedSymbol extends TransientSymbol { 4871 propertyType: Type; 4872 mappedType: MappedType; 4873 constraintType: IndexType; 4874 } 4875 4876 export const enum InternalSymbolName { 4877 Call = "__call", // Call signatures 4878 Constructor = "__constructor", // Constructor implementations 4879 New = "__new", // Constructor signatures 4880 Index = "__index", // Index signatures 4881 ExportStar = "__export", // Module export * declarations 4882 Global = "__global", // Global self-reference 4883 Missing = "__missing", // Indicates missing symbol 4884 Type = "__type", // Anonymous type literal symbol 4885 Object = "__object", // Anonymous object literal declaration 4886 JSXAttributes = "__jsxAttributes", // Anonymous JSX attributes object literal declaration 4887 Class = "__class", // Unnamed class expression 4888 Function = "__function", // Unnamed function expression 4889 Computed = "__computed", // Computed property name declaration with dynamic name 4890 Resolving = "__resolving__", // Indicator symbol used to mark partially resolved type aliases 4891 ExportEquals = "export=", // Export assignment symbol 4892 Default = "default", // Default export symbol (technically not wholly internal, but included here for usability) 4893 This = "this", 4894 } 4895 4896 /** 4897 * This represents a string whose leading underscore have been escaped by adding extra leading underscores. 4898 * The shape of this brand is rather unique compared to others we've used. 4899 * Instead of just an intersection of a string and an object, it is that union-ed 4900 * with an intersection of void and an object. This makes it wholly incompatible 4901 * with a normal string (which is good, it cannot be misused on assignment or on usage), 4902 * while still being comparable with a normal string via === (also good) and castable from a string. 4903 */ 4904 export type __String = (string & { __escapedIdentifier: void }) | (void & { __escapedIdentifier: void }) | InternalSymbolName; // eslint-disable-line @typescript-eslint/naming-convention 4905 4906 /** ReadonlyMap where keys are `__String`s. */ 4907 export interface ReadonlyUnderscoreEscapedMap<T> extends ReadonlyESMap<__String, T> { 4908 } 4909 4910 /** Map where keys are `__String`s. */ 4911 export interface UnderscoreEscapedMap<T> extends ESMap<__String, T>, ReadonlyUnderscoreEscapedMap<T> { 4912 } 4913 4914 /** SymbolTable based on ES6 Map interface. */ 4915 export type SymbolTable = UnderscoreEscapedMap<Symbol>; 4916 4917 /** Used to track a `declare module "foo*"`-like declaration. */ 4918 /* @internal */ 4919 export interface PatternAmbientModule { 4920 pattern: Pattern; 4921 symbol: Symbol; 4922 } 4923 4924 /* @internal */ 4925 export const enum NodeCheckFlags { 4926 TypeChecked = 0x00000001, // Node has been type checked 4927 LexicalThis = 0x00000002, // Lexical 'this' reference 4928 CaptureThis = 0x00000004, // Lexical 'this' used in body 4929 CaptureNewTarget = 0x00000008, // Lexical 'new.target' used in body 4930 SuperInstance = 0x00000100, // Instance 'super' reference 4931 SuperStatic = 0x00000200, // Static 'super' reference 4932 ContextChecked = 0x00000400, // Contextual types have been assigned 4933 AsyncMethodWithSuper = 0x00000800, // An async method that reads a value from a member of 'super'. 4934 AsyncMethodWithSuperBinding = 0x00001000, // An async method that assigns a value to a member of 'super'. 4935 CaptureArguments = 0x00002000, // Lexical 'arguments' used in body 4936 EnumValuesComputed = 0x00004000, // Values for enum members have been computed, and any errors have been reported for them. 4937 LexicalModuleMergesWithClass = 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. 4938 LoopWithCapturedBlockScopedBinding = 0x00010000, // Loop that contains block scoped variable captured in closure 4939 ContainsCapturedBlockScopeBinding = 0x00020000, // Part of a loop that contains block scoped variable captured in closure 4940 CapturedBlockScopedBinding = 0x00040000, // Block-scoped binding that is captured in some function 4941 BlockScopedBindingInLoop = 0x00080000, // Block-scoped binding with declaration nested inside iteration statement 4942 ClassWithBodyScopedClassBinding = 0x00100000, // Decorated class that contains a binding to itself inside of the class body. 4943 BodyScopedClassBinding = 0x00200000, // Binding to a decorated class inside of the class's body. 4944 NeedsLoopOutParameter = 0x00400000, // Block scoped binding whose value should be explicitly copied outside of the converted loop 4945 AssignmentsMarked = 0x00800000, // Parameter assignments have been marked 4946 ClassWithConstructorReference = 0x01000000, // Class that contains a binding to its constructor inside of the class body. 4947 ConstructorReferenceInClass = 0x02000000, // Binding to a class constructor inside of the class's body. 4948 ContainsClassWithPrivateIdentifiers = 0x04000000, // Marked on all block-scoped containers containing a class with private identifiers. 4949 } 4950 4951 /* @internal */ 4952 export interface NodeLinks { 4953 flags: NodeCheckFlags; // Set of flags specific to Node 4954 resolvedType?: Type; // Cached type of type node 4955 resolvedEnumType?: Type; // Cached constraint type from enum jsdoc tag 4956 resolvedSignature?: Signature; // Cached signature of signature node or call expression 4957 resolvedSymbol?: Symbol; // Cached name resolution result 4958 resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result 4959 effectsSignature?: Signature; // Signature with possible control flow effects 4960 enumMemberValue?: string | number; // Constant value of enum member 4961 isVisible?: boolean; // Is this node visible 4962 containsArgumentsReference?: boolean; // Whether a function-like declaration contains an 'arguments' reference 4963 hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context 4964 jsxFlags: JsxFlags; // flags for knowing what kind of element/attributes we're dealing with 4965 resolvedJsxElementAttributesType?: Type; // resolved element attributes type of a JSX openinglike element 4966 resolvedJsxElementAllAttributesType?: Type; // resolved all element attributes type of a JSX openinglike element 4967 resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference 4968 switchTypes?: Type[]; // Cached array of switch case expression types 4969 jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node 4970 jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to 4971 contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive 4972 deferredNodes?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred 4973 capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement 4974 outerTypeParameters?: TypeParameter[]; // Outer type parameters of anonymous object type 4975 isExhaustive?: boolean; // Is node an exhaustive switch statement 4976 skipDirectInference?: true; // Flag set by the API `getContextualType` call on a node when `Completions` is passed to force the checker to skip making inferences to a node's type 4977 declarationRequiresScopeChange?: boolean; // Set by `useOuterVariableScopeInParameter` in checker when downlevel emit would change the name resolution scope inside of a parameter. 4978 } 4979 4980 export const enum TypeFlags { 4981 Any = 1 << 0, 4982 Unknown = 1 << 1, 4983 String = 1 << 2, 4984 Number = 1 << 3, 4985 Boolean = 1 << 4, 4986 Enum = 1 << 5, 4987 BigInt = 1 << 6, 4988 StringLiteral = 1 << 7, 4989 NumberLiteral = 1 << 8, 4990 BooleanLiteral = 1 << 9, 4991 EnumLiteral = 1 << 10, // Always combined with StringLiteral, NumberLiteral, or Union 4992 BigIntLiteral = 1 << 11, 4993 ESSymbol = 1 << 12, // Type of symbol primitive introduced in ES6 4994 UniqueESSymbol = 1 << 13, // unique symbol 4995 Void = 1 << 14, 4996 Undefined = 1 << 15, 4997 Null = 1 << 16, 4998 Never = 1 << 17, // Never type 4999 TypeParameter = 1 << 18, // Type parameter 5000 Object = 1 << 19, // Object type 5001 Union = 1 << 20, // Union (T | U) 5002 Intersection = 1 << 21, // Intersection (T & U) 5003 Index = 1 << 22, // keyof T 5004 IndexedAccess = 1 << 23, // T[K] 5005 Conditional = 1 << 24, // T extends U ? X : Y 5006 Substitution = 1 << 25, // Type parameter substitution 5007 NonPrimitive = 1 << 26, // intrinsic object type 5008 TemplateLiteral = 1 << 27, // Template literal type 5009 StringMapping = 1 << 28, // Uppercase/Lowercase type 5010 5011 /* @internal */ 5012 AnyOrUnknown = Any | Unknown, 5013 /* @internal */ 5014 Nullable = Undefined | Null, 5015 Literal = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral, 5016 Unit = Literal | UniqueESSymbol | Nullable, 5017 StringOrNumberLiteral = StringLiteral | NumberLiteral, 5018 /* @internal */ 5019 StringOrNumberLiteralOrUnique = StringLiteral | NumberLiteral | UniqueESSymbol, 5020 /* @internal */ 5021 DefinitelyFalsy = StringLiteral | NumberLiteral | BigIntLiteral | BooleanLiteral | Void | Undefined | Null, 5022 PossiblyFalsy = DefinitelyFalsy | String | Number | BigInt | Boolean, 5023 /* @internal */ 5024 Intrinsic = Any | Unknown | String | Number | BigInt | Boolean | BooleanLiteral | ESSymbol | Void | Undefined | Null | Never | NonPrimitive, 5025 /* @internal */ 5026 Primitive = String | Number | BigInt | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol, 5027 StringLike = String | StringLiteral | TemplateLiteral | StringMapping, 5028 NumberLike = Number | NumberLiteral | Enum, 5029 BigIntLike = BigInt | BigIntLiteral, 5030 BooleanLike = Boolean | BooleanLiteral, 5031 EnumLike = Enum | EnumLiteral, 5032 ESSymbolLike = ESSymbol | UniqueESSymbol, 5033 VoidLike = Void | Undefined, 5034 /* @internal */ 5035 DisjointDomains = NonPrimitive | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbolLike | VoidLike | Null, 5036 UnionOrIntersection = Union | Intersection, 5037 StructuredType = Object | Union | Intersection, 5038 TypeVariable = TypeParameter | IndexedAccess, 5039 InstantiableNonPrimitive = TypeVariable | Conditional | Substitution, 5040 InstantiablePrimitive = Index | TemplateLiteral | StringMapping, 5041 Instantiable = InstantiableNonPrimitive | InstantiablePrimitive, 5042 StructuredOrInstantiable = StructuredType | Instantiable, 5043 /* @internal */ 5044 ObjectFlagsType = Any | Nullable | Never | Object | Union | Intersection, 5045 /* @internal */ 5046 Simplifiable = IndexedAccess | Conditional, 5047 /* @internal */ 5048 Substructure = Object | Union | Intersection | Index | IndexedAccess | Conditional | Substitution | TemplateLiteral | StringMapping, 5049 // 'Narrowable' types are types where narrowing actually narrows. 5050 // This *should* be every type other than null, undefined, void, and never 5051 Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive, 5052 /* @internal */ 5053 NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | Object | Intersection | Instantiable, 5054 // The following flags are aggregated during union and intersection type construction 5055 /* @internal */ 5056 IncludesMask = Any | Unknown | Primitive | Never | Object | Union | Intersection | NonPrimitive | TemplateLiteral, 5057 // The following flags are used for different purposes during union and intersection type construction 5058 /* @internal */ 5059 IncludesStructuredOrInstantiable = TypeParameter, 5060 /* @internal */ 5061 IncludesNonWideningType = Index, 5062 /* @internal */ 5063 IncludesWildcard = IndexedAccess, 5064 /* @internal */ 5065 IncludesEmptyObject = Conditional, 5066 } 5067 5068 export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; 5069 5070 /* @internal */ 5071 export type TypeId = number; 5072 5073 // Properties common to all types 5074 export interface Type { 5075 flags: TypeFlags; // Flags 5076 /* @internal */ id: TypeId; // Unique ID 5077 /* @internal */ checker: TypeChecker; 5078 symbol: Symbol; // Symbol associated with type (if any) 5079 pattern?: DestructuringPattern; // Destructuring pattern represented by type (if any) 5080 aliasSymbol?: Symbol; // Alias associated with type 5081 aliasTypeArguments?: readonly Type[]; // Alias type arguments (if any) 5082 /* @internal */ aliasTypeArgumentsContainsMarker?: boolean; // Alias type arguments (if any) 5083 /* @internal */ 5084 permissiveInstantiation?: Type; // Instantiation with type parameters mapped to wildcard type 5085 /* @internal */ 5086 restrictiveInstantiation?: Type; // Instantiation with type parameters mapped to unconstrained form 5087 /* @internal */ 5088 immediateBaseConstraint?: Type; // Immediate base constraint cache 5089 /* @internal */ 5090 widened?: Type; // Cached widened form of the type 5091 } 5092 5093 /* @internal */ 5094 // Intrinsic types (TypeFlags.Intrinsic) 5095 export interface IntrinsicType extends Type { 5096 intrinsicName: string; // Name of intrinsic type 5097 objectFlags: ObjectFlags; 5098 } 5099 5100 /* @internal */ 5101 export interface NullableType extends IntrinsicType { 5102 objectFlags: ObjectFlags; 5103 } 5104 5105 /* @internal */ 5106 export interface FreshableIntrinsicType extends IntrinsicType { 5107 freshType: IntrinsicType; // Fresh version of type 5108 regularType: IntrinsicType; // Regular version of type 5109 } 5110 5111 /* @internal */ 5112 export type FreshableType = LiteralType | FreshableIntrinsicType; 5113 5114 // String literal types (TypeFlags.StringLiteral) 5115 // Numeric literal types (TypeFlags.NumberLiteral) 5116 // BigInt literal types (TypeFlags.BigIntLiteral) 5117 export interface LiteralType extends Type { 5118 value: string | number | PseudoBigInt; // Value of literal 5119 freshType: LiteralType; // Fresh version of type 5120 regularType: LiteralType; // Regular version of type 5121 } 5122 5123 // Unique symbol types (TypeFlags.UniqueESSymbol) 5124 export interface UniqueESSymbolType extends Type { 5125 symbol: Symbol; 5126 escapedName: __String; 5127 } 5128 5129 export interface StringLiteralType extends LiteralType { 5130 value: string; 5131 } 5132 5133 export interface NumberLiteralType extends LiteralType { 5134 value: number; 5135 } 5136 5137 export interface BigIntLiteralType extends LiteralType { 5138 value: PseudoBigInt; 5139 } 5140 5141 // Enum types (TypeFlags.Enum) 5142 export interface EnumType extends Type { 5143 } 5144 5145 export const enum ObjectFlags { 5146 Class = 1 << 0, // Class 5147 Interface = 1 << 1, // Interface 5148 Reference = 1 << 2, // Generic type reference 5149 Tuple = 1 << 3, // Synthesized generic tuple type 5150 Anonymous = 1 << 4, // Anonymous 5151 Mapped = 1 << 5, // Mapped 5152 Instantiated = 1 << 6, // Instantiated anonymous or mapped type 5153 ObjectLiteral = 1 << 7, // Originates in an object literal 5154 EvolvingArray = 1 << 8, // Evolving array type 5155 ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties 5156 ContainsSpread = 1 << 10, // Object literal contains spread operation 5157 ReverseMapped = 1 << 11, // Object contains a property from a reverse-mapped type 5158 JsxAttributes = 1 << 12, // Jsx attributes type 5159 MarkerType = 1 << 13, // Marker type used for variance probing 5160 JSLiteral = 1 << 14, // Object type declared in JS - disables errors on read/write of nonexisting members 5161 FreshLiteral = 1 << 15, // Fresh object literal 5162 ArrayLiteral = 1 << 16, // Originates in an array literal 5163 ObjectRestType = 1 << 17, // Originates in object rest declaration 5164 /* @internal */ 5165 PrimitiveUnion = 1 << 18, // Union of only primitive types 5166 /* @internal */ 5167 ContainsWideningType = 1 << 19, // Type is or contains undefined or null widening type 5168 /* @internal */ 5169 ContainsObjectOrArrayLiteral = 1 << 20, // Type is or contains object literal type 5170 /* @internal */ 5171 NonInferrableType = 1 << 21, // Type is or contains anyFunctionType or silentNeverType 5172 /* @internal */ 5173 IsGenericObjectTypeComputed = 1 << 22, // IsGenericObjectType flag has been computed 5174 /* @internal */ 5175 IsGenericObjectType = 1 << 23, // Union or intersection contains generic object type 5176 /* @internal */ 5177 IsGenericIndexTypeComputed = 1 << 24, // IsGenericIndexType flag has been computed 5178 /* @internal */ 5179 IsGenericIndexType = 1 << 25, // Union or intersection contains generic index type 5180 /* @internal */ 5181 CouldContainTypeVariablesComputed = 1 << 26, // CouldContainTypeVariables flag has been computed 5182 /* @internal */ 5183 CouldContainTypeVariables = 1 << 27, // Type could contain a type variable 5184 /* @internal */ 5185 ContainsIntersections = 1 << 28, // Union contains intersections 5186 /* @internal */ 5187 IsNeverIntersectionComputed = 1 << 28, // IsNeverLike flag has been computed 5188 /* @internal */ 5189 IsNeverIntersection = 1 << 29, // Intersection reduces to never 5190 /* @internal */ 5191 IsClassInstanceClone = 1 << 30, // Type is a clone of a class instance type 5192 ClassOrInterface = Class | Interface, 5193 /* @internal */ 5194 RequiresWidening = ContainsWideningType | ContainsObjectOrArrayLiteral, 5195 /* @internal */ 5196 PropagatingFlags = ContainsWideningType | ContainsObjectOrArrayLiteral | NonInferrableType, 5197 5198 // Object flags that uniquely identify the kind of ObjectType 5199 /* @internal */ 5200 ObjectTypeKindMask = ClassOrInterface | Reference | Tuple | Anonymous | Mapped | ReverseMapped | EvolvingArray, 5201 } 5202 5203 /* @internal */ 5204 export type ObjectFlagsType = NullableType | ObjectType | UnionType | IntersectionType; 5205 5206 // Object types (TypeFlags.ObjectType) 5207 export interface ObjectType extends Type { 5208 objectFlags: ObjectFlags; 5209 /* @internal */ members?: SymbolTable; // Properties by name 5210 /* @internal */ properties?: Symbol[]; // Properties 5211 /* @internal */ callSignatures?: readonly Signature[]; // Call signatures of type 5212 /* @internal */ constructSignatures?: readonly Signature[]; // Construct signatures of type 5213 /* @internal */ stringIndexInfo?: IndexInfo; // String indexing info 5214 /* @internal */ numberIndexInfo?: IndexInfo; // Numeric indexing info 5215 /* @internal */ objectTypeWithoutAbstractConstructSignatures?: ObjectType; 5216 } 5217 5218 /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ 5219 export interface InterfaceType extends ObjectType { 5220 typeParameters: TypeParameter[] | undefined; // Type parameters (undefined if non-generic) 5221 outerTypeParameters: TypeParameter[] | undefined; // Outer type parameters (undefined if none) 5222 localTypeParameters: TypeParameter[] | undefined; // Local type parameters (undefined if none) 5223 thisType: TypeParameter | undefined; // The "this" type (undefined if none) 5224 /* @internal */ 5225 resolvedBaseConstructorType?: Type; // Resolved base constructor type of class 5226 /* @internal */ 5227 resolvedBaseTypes: BaseType[]; // Resolved base types 5228 /* @internal */ 5229 baseTypesResolved?: boolean; 5230 } 5231 5232 // Object type or intersection of object types 5233 export type BaseType = ObjectType | IntersectionType | TypeVariable; // Also `any` and `object` 5234 5235 export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { 5236 declaredProperties: Symbol[]; // Declared members 5237 declaredCallSignatures: Signature[]; // Declared call signatures 5238 declaredConstructSignatures: Signature[]; // Declared construct signatures 5239 declaredStringIndexInfo?: IndexInfo; // Declared string indexing info 5240 declaredNumberIndexInfo?: IndexInfo; // Declared numeric indexing info 5241 } 5242 5243 /** 5244 * Type references (ObjectFlags.Reference). When a class or interface has type parameters or 5245 * a "this" type, references to the class or interface are made using type references. The 5246 * typeArguments property specifies the types to substitute for the type parameters of the 5247 * class or interface and optionally includes an extra element that specifies the type to 5248 * substitute for "this" in the resulting instantiation. When no extra argument is present, 5249 * the type reference itself is substituted for "this". The typeArguments property is undefined 5250 * if the class or interface has no type parameters and the reference isn't specifying an 5251 * explicit "this" argument. 5252 */ 5253 export interface TypeReference extends ObjectType { 5254 target: GenericType; // Type reference target 5255 node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; 5256 /* @internal */ 5257 mapper?: TypeMapper; 5258 /* @internal */ 5259 resolvedTypeArguments?: readonly Type[]; // Resolved type reference type arguments 5260 /* @internal */ 5261 literalType?: TypeReference; // Clone of type with ObjectFlags.ArrayLiteral set 5262 } 5263 5264 export interface DeferredTypeReference extends TypeReference { 5265 /* @internal */ 5266 node: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; 5267 /* @internal */ 5268 mapper?: TypeMapper; 5269 /* @internal */ 5270 instantiations?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic) 5271 } 5272 5273 /* @internal */ 5274 export const enum VarianceFlags { 5275 Invariant = 0, // Neither covariant nor contravariant 5276 Covariant = 1 << 0, // Covariant 5277 Contravariant = 1 << 1, // Contravariant 5278 Bivariant = Covariant | Contravariant, // Both covariant and contravariant 5279 Independent = 1 << 2, // Unwitnessed type parameter 5280 VarianceMask = Invariant | Covariant | Contravariant | Independent, // Mask containing all measured variances without the unmeasurable flag 5281 Unmeasurable = 1 << 3, // Variance result is unusable - relationship relies on structural comparisons which are not reflected in generic relationships 5282 Unreliable = 1 << 4, // Variance result is unreliable - checking may produce false negatives, but not false positives 5283 AllowsStructuralFallback = Unmeasurable | Unreliable, 5284 } 5285 5286 // Generic class and interface types 5287 export interface GenericType extends InterfaceType, TypeReference { 5288 /* @internal */ 5289 instantiations: ESMap<string, TypeReference>; // Generic instantiation cache 5290 /* @internal */ 5291 variances?: VarianceFlags[]; // Variance of each type parameter 5292 } 5293 5294 export const enum ElementFlags { 5295 Required = 1 << 0, // T 5296 Optional = 1 << 1, // T? 5297 Rest = 1 << 2, // ...T[] 5298 Variadic = 1 << 3, // ...T 5299 Fixed = Required | Optional, 5300 Variable = Rest | Variadic, 5301 NonRequired = Optional | Rest | Variadic, 5302 NonRest = Required | Optional | Variadic, 5303 } 5304 5305 export interface TupleType extends GenericType { 5306 elementFlags: readonly ElementFlags[]; 5307 minLength: number; // Number of required or variadic elements 5308 fixedLength: number; // Number of initial required or optional elements 5309 hasRestElement: boolean; // True if tuple has any rest or variadic elements 5310 combinedFlags: ElementFlags; 5311 readonly: boolean; 5312 labeledElementDeclarations?: readonly (NamedTupleMember | ParameterDeclaration)[]; 5313 } 5314 5315 export interface TupleTypeReference extends TypeReference { 5316 target: TupleType; 5317 } 5318 5319 export interface UnionOrIntersectionType extends Type { 5320 types: Type[]; // Constituent types 5321 /* @internal */ 5322 objectFlags: ObjectFlags; 5323 /* @internal */ 5324 propertyCache?: SymbolTable; // Cache of resolved properties 5325 /* @internal */ 5326 propertyCacheWithoutObjectFunctionPropertyAugment?: SymbolTable; // Cache of resolved properties that does not augment function or object type properties 5327 /* @internal */ 5328 resolvedProperties: Symbol[]; 5329 /* @internal */ 5330 resolvedIndexType: IndexType; 5331 /* @internal */ 5332 resolvedStringIndexType: IndexType; 5333 /* @internal */ 5334 resolvedBaseConstraint: Type; 5335 } 5336 5337 export interface UnionType extends UnionOrIntersectionType { 5338 /* @internal */ 5339 resolvedReducedType?: Type; 5340 /* @internal */ 5341 regularType?: UnionType; 5342 /* @internal */ 5343 origin?: Type; // Denormalized union, intersection, or index type in which union originates 5344 } 5345 5346 export interface IntersectionType extends UnionOrIntersectionType { 5347 /* @internal */ 5348 resolvedApparentType: Type; 5349 } 5350 5351 export type StructuredType = ObjectType | UnionType | IntersectionType; 5352 5353 /* @internal */ 5354 // An instantiated anonymous type has a target and a mapper 5355 export interface AnonymousType extends ObjectType { 5356 target?: AnonymousType; // Instantiation target 5357 mapper?: TypeMapper; // Instantiation mapper 5358 instantiations?: ESMap<string, Type>; // Instantiations of generic type alias (undefined if non-generic) 5359 } 5360 5361 /* @internal */ 5362 export interface MappedType extends AnonymousType { 5363 declaration: MappedTypeNode; 5364 typeParameter?: TypeParameter; 5365 constraintType?: Type; 5366 nameType?: Type; 5367 templateType?: Type; 5368 modifiersType?: Type; 5369 resolvedApparentType?: Type; 5370 containsError?: boolean; 5371 } 5372 5373 export interface EvolvingArrayType extends ObjectType { 5374 elementType: Type; // Element expressions of evolving array type 5375 finalArrayType?: Type; // Final array type of evolving array type 5376 } 5377 5378 /* @internal */ 5379 export interface ReverseMappedType extends ObjectType { 5380 source: Type; 5381 mappedType: MappedType; 5382 constraintType: IndexType; 5383 } 5384 5385 /* @internal */ 5386 // Resolved object, union, or intersection type 5387 export interface ResolvedType extends ObjectType, UnionOrIntersectionType { 5388 members: SymbolTable; // Properties by name 5389 properties: Symbol[]; // Properties 5390 callSignatures: readonly Signature[]; // Call signatures of type 5391 constructSignatures: readonly Signature[]; // Construct signatures of type 5392 } 5393 5394 /* @internal */ 5395 // Object literals are initially marked fresh. Freshness disappears following an assignment, 5396 // before a type assertion, or when an object literal's type is widened. The regular 5397 // version of a fresh type is identical except for the TypeFlags.FreshObjectLiteral flag. 5398 export interface FreshObjectLiteralType extends ResolvedType { 5399 regularType: ResolvedType; // Regular version of fresh type 5400 } 5401 5402 /* @internal */ 5403 export interface IterationTypes { 5404 readonly yieldType: Type; 5405 readonly returnType: Type; 5406 readonly nextType: Type; 5407 } 5408 5409 // Just a place to cache element types of iterables and iterators 5410 /* @internal */ 5411 export interface IterableOrIteratorType extends ObjectType, UnionType { 5412 iterationTypesOfGeneratorReturnType?: IterationTypes; 5413 iterationTypesOfAsyncGeneratorReturnType?: IterationTypes; 5414 iterationTypesOfIterable?: IterationTypes; 5415 iterationTypesOfIterator?: IterationTypes; 5416 iterationTypesOfAsyncIterable?: IterationTypes; 5417 iterationTypesOfAsyncIterator?: IterationTypes; 5418 iterationTypesOfIteratorResult?: IterationTypes; 5419 } 5420 5421 /* @internal */ 5422 export interface PromiseOrAwaitableType extends ObjectType, UnionType { 5423 promiseTypeOfPromiseConstructor?: Type; 5424 promisedTypeOfPromise?: Type; 5425 awaitedTypeOfType?: Type; 5426 } 5427 5428 /* @internal */ 5429 export interface SyntheticDefaultModuleType extends Type { 5430 syntheticType?: Type; 5431 } 5432 5433 export interface InstantiableType extends Type { 5434 /* @internal */ 5435 resolvedBaseConstraint?: Type; 5436 /* @internal */ 5437 resolvedIndexType?: IndexType; 5438 /* @internal */ 5439 resolvedStringIndexType?: IndexType; 5440 } 5441 5442 // Type parameters (TypeFlags.TypeParameter) 5443 export interface TypeParameter extends InstantiableType { 5444 /** Retrieve using getConstraintFromTypeParameter */ 5445 /* @internal */ 5446 constraint?: Type; // Constraint 5447 /* @internal */ 5448 default?: Type; 5449 /* @internal */ 5450 target?: TypeParameter; // Instantiation target 5451 /* @internal */ 5452 mapper?: TypeMapper; // Instantiation mapper 5453 /* @internal */ 5454 isThisType?: boolean; 5455 /* @internal */ 5456 resolvedDefaultType?: Type; 5457 } 5458 5459 // Indexed access types (TypeFlags.IndexedAccess) 5460 // Possible forms are T[xxx], xxx[T], or xxx[keyof T], where T is a type variable 5461 export interface IndexedAccessType extends InstantiableType { 5462 objectType: Type; 5463 indexType: Type; 5464 /** 5465 * @internal 5466 * Indicates that --noUncheckedIndexedAccess may introduce 'undefined' into 5467 * the resulting type, depending on how type variable constraints are resolved. 5468 */ 5469 noUncheckedIndexedAccessCandidate: boolean; 5470 constraint?: Type; 5471 simplifiedForReading?: Type; 5472 simplifiedForWriting?: Type; 5473 } 5474 5475 export type TypeVariable = TypeParameter | IndexedAccessType; 5476 5477 // keyof T types (TypeFlags.Index) 5478 export interface IndexType extends InstantiableType { 5479 type: InstantiableType | UnionOrIntersectionType; 5480 /* @internal */ 5481 stringsOnly: boolean; 5482 } 5483 5484 export interface ConditionalRoot { 5485 node: ConditionalTypeNode; 5486 checkType: Type; 5487 extendsType: Type; 5488 isDistributive: boolean; 5489 inferTypeParameters?: TypeParameter[]; 5490 outerTypeParameters?: TypeParameter[]; 5491 instantiations?: Map<Type>; 5492 aliasSymbol?: Symbol; 5493 aliasTypeArguments?: Type[]; 5494 } 5495 5496 // T extends U ? X : Y (TypeFlags.Conditional) 5497 export interface ConditionalType extends InstantiableType { 5498 root: ConditionalRoot; 5499 checkType: Type; 5500 extendsType: Type; 5501 resolvedTrueType: Type; 5502 resolvedFalseType: Type; 5503 /* @internal */ 5504 resolvedInferredTrueType?: Type; // The `trueType` instantiated with the `combinedMapper`, if present 5505 /* @internal */ 5506 resolvedDefaultConstraint?: Type; 5507 /* @internal */ 5508 mapper?: TypeMapper; 5509 /* @internal */ 5510 combinedMapper?: TypeMapper; 5511 } 5512 5513 export interface TemplateLiteralType extends InstantiableType { 5514 texts: readonly string[]; // Always one element longer than types 5515 types: readonly Type[]; // Always at least one element 5516 } 5517 5518 export interface StringMappingType extends InstantiableType { 5519 symbol: Symbol; 5520 type: Type; 5521 } 5522 5523 // Type parameter substitution (TypeFlags.Substitution) 5524 // Substitution types are created for type parameters or indexed access types that occur in the 5525 // true branch of a conditional type. For example, in 'T extends string ? Foo<T> : Bar<T>', the 5526 // reference to T in Foo<T> is resolved as a substitution type that substitutes 'string & T' for T. 5527 // Thus, if Foo has a 'string' constraint on its type parameter, T will satisfy it. Substitution 5528 // types disappear upon instantiation (just like type parameters). 5529 export interface SubstitutionType extends InstantiableType { 5530 baseType: Type; // Target type 5531 substitute: Type; // Type to substitute for type parameter 5532 } 5533 5534 /* @internal */ 5535 export const enum JsxReferenceKind { 5536 Component, 5537 Function, 5538 Mixed 5539 } 5540 5541 export const enum SignatureKind { 5542 Call, 5543 Construct, 5544 } 5545 5546 /* @internal */ 5547 export const enum SignatureFlags { 5548 None = 0, 5549 5550 // Propagating flags 5551 HasRestParameter = 1 << 0, // Indicates last parameter is rest parameter 5552 HasLiteralTypes = 1 << 1, // Indicates signature is specialized 5553 Abstract = 1 << 2, // Indicates signature comes from an abstract class, abstract construct signature, or abstract constructor type 5554 5555 // Non-propagating flags 5556 IsInnerCallChain = 1 << 3, // Indicates signature comes from a CallChain nested in an outer OptionalChain 5557 IsOuterCallChain = 1 << 4, // Indicates signature comes from a CallChain that is the outermost chain of an optional expression 5558 IsUntypedSignatureInJSFile = 1 << 5, // Indicates signature is from a js file and has no types 5559 5560 // We do not propagate `IsInnerCallChain` or `IsOuterCallChain` to instantiated signatures, as that would result in us 5561 // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when 5562 // instantiating the return type. 5563 PropagatingFlags = HasRestParameter | HasLiteralTypes | Abstract | IsUntypedSignatureInJSFile, 5564 5565 CallChainFlags = IsInnerCallChain | IsOuterCallChain, 5566 } 5567 5568 export interface Signature { 5569 /* @internal */ flags: SignatureFlags; 5570 /* @internal */ checker?: TypeChecker; 5571 declaration?: SignatureDeclaration | JSDocSignature; // Originating declaration 5572 typeParameters?: readonly TypeParameter[]; // Type parameters (undefined if non-generic) 5573 parameters: readonly Symbol[]; // Parameters 5574 /* @internal */ 5575 thisParameter?: Symbol; // symbol of this-type parameter 5576 /* @internal */ 5577 // See comment in `instantiateSignature` for why these are set lazily. 5578 resolvedReturnType?: Type; // Lazily set by `getReturnTypeOfSignature`. 5579 /* @internal */ 5580 // Lazily set by `getTypePredicateOfSignature`. 5581 // `undefined` indicates a type predicate that has not yet been computed. 5582 // Uses a special `noTypePredicate` sentinel value to indicate that there is no type predicate. This looks like a TypePredicate at runtime to avoid polymorphism. 5583 resolvedTypePredicate?: TypePredicate; 5584 /* @internal */ 5585 minArgumentCount: number; // Number of non-optional parameters 5586 /* @internal */ 5587 resolvedMinArgumentCount?: number; // Number of non-optional parameters (excluding trailing `void`) 5588 /* @internal */ 5589 target?: Signature; // Instantiation target 5590 /* @internal */ 5591 mapper?: TypeMapper; // Instantiation mapper 5592 /* @internal */ 5593 unionSignatures?: Signature[]; // Underlying signatures of a union signature 5594 /* @internal */ 5595 erasedSignatureCache?: Signature; // Erased version of signature (deferred) 5596 /* @internal */ 5597 canonicalSignatureCache?: Signature; // Canonical version of signature (deferred) 5598 /* @internal */ 5599 optionalCallSignatureCache?: { inner?: Signature, outer?: Signature }; // Optional chained call version of signature (deferred) 5600 /* @internal */ 5601 isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison 5602 /* @internal */ 5603 instantiations?: ESMap<string, Signature>; // Generic signature instantiation cache 5604 } 5605 5606 export const enum IndexKind { 5607 String, 5608 Number, 5609 } 5610 5611 export interface IndexInfo { 5612 type: Type; 5613 isReadonly: boolean; 5614 declaration?: IndexSignatureDeclaration; 5615 } 5616 5617 /* @internal */ 5618 export const enum TypeMapKind { 5619 Simple, 5620 Array, 5621 Function, 5622 Composite, 5623 Merged, 5624 } 5625 5626 /* @internal */ 5627 export type TypeMapper = 5628 | { kind: TypeMapKind.Simple, source: Type, target: Type } 5629 | { kind: TypeMapKind.Array, sources: readonly Type[], targets: readonly Type[] | undefined } 5630 | { kind: TypeMapKind.Function, func: (t: Type) => Type } 5631 | { kind: TypeMapKind.Composite | TypeMapKind.Merged, mapper1: TypeMapper, mapper2: TypeMapper }; 5632 5633 export const enum InferencePriority { 5634 NakedTypeVariable = 1 << 0, // Naked type variable in union or intersection type 5635 SpeculativeTuple = 1 << 1, // Speculative tuple inference 5636 HomomorphicMappedType = 1 << 2, // Reverse inference for homomorphic mapped type 5637 PartialHomomorphicMappedType = 1 << 3, // Partial reverse inference for homomorphic mapped type 5638 MappedTypeConstraint = 1 << 4, // Reverse inference for mapped type 5639 ContravariantConditional = 1 << 5, // Conditional type in contravariant position 5640 ReturnType = 1 << 6, // Inference made from return type of generic function 5641 LiteralKeyof = 1 << 7, // Inference made from a string literal to a keyof T 5642 NoConstraints = 1 << 8, // Don't infer from constraints of instantiable types 5643 AlwaysStrict = 1 << 9, // Always use strict rules for contravariant inferences 5644 MaxValue = 1 << 10, // Seed for inference priority tracking 5645 5646 PriorityImpliesCombination = ReturnType | MappedTypeConstraint | LiteralKeyof, // These priorities imply that the resulting type should be a combination of all candidates 5647 Circularity = -1, // Inference circularity (value less than all other priorities) 5648 } 5649 5650 /* @internal */ 5651 export interface InferenceInfo { 5652 typeParameter: TypeParameter; // Type parameter for which inferences are being made 5653 candidates: Type[] | undefined; // Candidates in covariant positions (or undefined) 5654 contraCandidates: Type[] | undefined; // Candidates in contravariant positions (or undefined) 5655 inferredType?: Type; // Cache for resolved inferred type 5656 priority?: InferencePriority; // Priority of current inference set 5657 topLevel: boolean; // True if all inferences are to top level occurrences 5658 isFixed: boolean; // True if inferences are fixed 5659 impliedArity?: number; 5660 } 5661 5662 /* @internal */ 5663 export const enum InferenceFlags { 5664 None = 0, // No special inference behaviors 5665 NoDefault = 1 << 0, // Infer unknownType for no inferences (otherwise anyType or emptyObjectType) 5666 AnyDefault = 1 << 1, // Infer anyType for no inferences (otherwise emptyObjectType) 5667 SkippedGenericFunction = 1 << 2, // A generic function was skipped during inference 5668 } 5669 5670 /** 5671 * Ternary values are defined such that 5672 * x & y picks the lesser in the order False < Unknown < Maybe < True, and 5673 * x | y picks the greater in the order False < Unknown < Maybe < True. 5674 * Generally, Ternary.Maybe is used as the result of a relation that depends on itself, and 5675 * Ternary.Unknown is used as the result of a variance check that depends on itself. We make 5676 * a distinction because we don't want to cache circular variance check results. 5677 */ 5678 /* @internal */ 5679 export const enum Ternary { 5680 False = 0, 5681 Unknown = 1, 5682 Maybe = 3, 5683 True = -1 5684 } 5685 5686 /* @internal */ 5687 export type TypeComparer = (s: Type, t: Type, reportErrors?: boolean) => Ternary; 5688 5689 /* @internal */ 5690 export interface InferenceContext { 5691 inferences: InferenceInfo[]; // Inferences made for each type parameter 5692 signature?: Signature; // Generic signature for which inferences are made (if any) 5693 flags: InferenceFlags; // Inference flags 5694 compareTypes: TypeComparer; // Type comparer function 5695 mapper: TypeMapper; // Mapper that fixes inferences 5696 nonFixingMapper: TypeMapper; // Mapper that doesn't fix inferences 5697 returnMapper?: TypeMapper; // Type mapper for inferences from return types (if any) 5698 inferredTypeParameters?: readonly TypeParameter[]; // Inferred type parameters for function result 5699 } 5700 5701 /* @internal */ 5702 export interface WideningContext { 5703 parent?: WideningContext; // Parent context 5704 propertyName?: __String; // Name of property in parent 5705 siblings?: Type[]; // Types of siblings 5706 resolvedProperties?: Symbol[]; // Properties occurring in sibling object literals 5707 } 5708 5709 /* @internal */ 5710 export const enum AssignmentDeclarationKind { 5711 None, 5712 /// exports.name = expr 5713 /// module.exports.name = expr 5714 ExportsProperty, 5715 /// module.exports = expr 5716 ModuleExports, 5717 /// className.prototype.name = expr 5718 PrototypeProperty, 5719 /// this.name = expr 5720 ThisProperty, 5721 // F.name = expr 5722 Property, 5723 // F.prototype = { ... } 5724 Prototype, 5725 // Object.defineProperty(x, 'name', { value: any, writable?: boolean (false by default) }); 5726 // Object.defineProperty(x, 'name', { get: Function, set: Function }); 5727 // Object.defineProperty(x, 'name', { get: Function }); 5728 // Object.defineProperty(x, 'name', { set: Function }); 5729 ObjectDefinePropertyValue, 5730 // Object.defineProperty(exports || module.exports, 'name', ...); 5731 ObjectDefinePropertyExports, 5732 // Object.defineProperty(Foo.prototype, 'name', ...); 5733 ObjectDefinePrototypeProperty, 5734 } 5735 5736 /** @deprecated Use FileExtensionInfo instead. */ 5737 export type JsFileExtensionInfo = FileExtensionInfo; 5738 5739 export interface FileExtensionInfo { 5740 extension: string; 5741 isMixedContent: boolean; 5742 scriptKind?: ScriptKind; 5743 } 5744 5745 export interface DiagnosticMessage { 5746 key: string; 5747 category: DiagnosticCategory; 5748 code: number; 5749 message: string; 5750 reportsUnnecessary?: {}; 5751 reportsDeprecated?: {}; 5752 /* @internal */ 5753 elidedInCompatabilityPyramid?: boolean; 5754 } 5755 5756 /** 5757 * A linked list of formatted diagnostic messages to be used as part of a multiline message. 5758 * It is built from the bottom up, leaving the head to be the "main" diagnostic. 5759 * While it seems that DiagnosticMessageChain is structurally similar to DiagnosticMessage, 5760 * the difference is that messages are all preformatted in DMC. 5761 */ 5762 export interface DiagnosticMessageChain { 5763 messageText: string; 5764 category: DiagnosticCategory; 5765 code: number; 5766 next?: DiagnosticMessageChain[]; 5767 } 5768 5769 export interface Diagnostic extends DiagnosticRelatedInformation { 5770 /** May store more in future. For now, this will simply be `true` to indicate when a diagnostic is an unused-identifier diagnostic. */ 5771 reportsUnnecessary?: {}; 5772 5773 reportsDeprecated?: {} 5774 source?: string; 5775 relatedInformation?: DiagnosticRelatedInformation[]; 5776 /* @internal */ skippedOn?: keyof CompilerOptions; 5777 } 5778 5779 export interface DiagnosticRelatedInformation { 5780 category: DiagnosticCategory; 5781 code: number; 5782 file: SourceFile | undefined; 5783 start: number | undefined; 5784 length: number | undefined; 5785 messageText: string | DiagnosticMessageChain; 5786 } 5787 5788 export interface DiagnosticWithLocation extends Diagnostic { 5789 file: SourceFile; 5790 start: number; 5791 length: number; 5792 } 5793 5794 /* @internal*/ 5795 export interface DiagnosticWithDetachedLocation extends Diagnostic { 5796 file: undefined; 5797 fileName: string; 5798 start: number; 5799 length: number; 5800 } 5801 5802 export enum DiagnosticCategory { 5803 Warning, 5804 Error, 5805 Suggestion, 5806 Message 5807 } 5808 /* @internal */ 5809 export function diagnosticCategoryName(d: { category: DiagnosticCategory }, lowerCase = true): string { 5810 const name = DiagnosticCategory[d.category]; 5811 return lowerCase ? name.toLowerCase() : name; 5812 } 5813 5814 export enum ModuleResolutionKind { 5815 Classic = 1, 5816 NodeJs = 2 5817 } 5818 5819 export interface PluginImport { 5820 name: string; 5821 } 5822 5823 export interface ProjectReference { 5824 /** A normalized path on disk */ 5825 path: string; 5826 /** The path as the user originally wrote it */ 5827 originalPath?: string; 5828 /** True if the output of this reference should be prepended to the output of this project. Only valid for --outFile compilations */ 5829 prepend?: boolean; 5830 /** True if it is intended that this reference form a circularity */ 5831 circular?: boolean; 5832 } 5833 5834 export enum WatchFileKind { 5835 FixedPollingInterval, 5836 PriorityPollingInterval, 5837 DynamicPriorityPolling, 5838 UseFsEvents, 5839 UseFsEventsOnParentDirectory, 5840 } 5841 5842 export enum WatchDirectoryKind { 5843 UseFsEvents, 5844 FixedPollingInterval, 5845 DynamicPriorityPolling, 5846 } 5847 5848 export enum PollingWatchKind { 5849 FixedInterval, 5850 PriorityInterval, 5851 DynamicPriority, 5852 } 5853 5854 export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike<string[]> | PluginImport[] | ProjectReference[] | null | undefined | EtsOptions; 5855 5856 export interface CompilerOptions { 5857 /*@internal*/ all?: boolean; 5858 allowJs?: boolean; 5859 /*@internal*/ allowNonTsExtensions?: boolean; 5860 allowSyntheticDefaultImports?: boolean; 5861 allowUmdGlobalAccess?: boolean; 5862 allowUnreachableCode?: boolean; 5863 allowUnusedLabels?: boolean; 5864 alwaysStrict?: boolean; // Always combine with strict property 5865 baseUrl?: string; 5866 /** An error if set - this should only go through the -b pipeline and not actually be observed */ 5867 /*@internal*/ 5868 build?: boolean; 5869 charset?: string; 5870 checkJs?: boolean; 5871 /* @internal */ configFilePath?: string; 5872 /** configFile is set as non enumerable property so as to avoid checking of json source files */ 5873 /* @internal */ readonly configFile?: TsConfigSourceFile; 5874 declaration?: boolean; 5875 declarationMap?: boolean; 5876 emitDeclarationOnly?: boolean; 5877 declarationDir?: string; 5878 /* @internal */ diagnostics?: boolean; 5879 /* @internal */ extendedDiagnostics?: boolean; 5880 disableSizeLimit?: boolean; 5881 disableSourceOfProjectReferenceRedirect?: boolean; 5882 disableSolutionSearching?: boolean; 5883 disableReferencedProjectLoad?: boolean; 5884 downlevelIteration?: boolean; 5885 emitBOM?: boolean; 5886 emitDecoratorMetadata?: boolean; 5887 experimentalDecorators?: boolean; 5888 forceConsistentCasingInFileNames?: boolean; 5889 /*@internal*/generateCpuProfile?: string; 5890 /*@internal*/generateTrace?: string; 5891 /*@internal*/help?: boolean; 5892 importHelpers?: boolean; 5893 importsNotUsedAsValues?: ImportsNotUsedAsValues; 5894 /*@internal*/init?: boolean; 5895 inlineSourceMap?: boolean; 5896 inlineSources?: boolean; 5897 isolatedModules?: boolean; 5898 jsx?: JsxEmit; 5899 keyofStringsOnly?: boolean; 5900 lib?: string[]; 5901 /*@internal*/listEmittedFiles?: boolean; 5902 /*@internal*/listFiles?: boolean; 5903 /*@internal*/explainFiles?: boolean; 5904 /*@internal*/listFilesOnly?: boolean; 5905 locale?: string; 5906 mapRoot?: string; 5907 maxNodeModuleJsDepth?: number; 5908 module?: ModuleKind; 5909 moduleResolution?: ModuleResolutionKind; 5910 newLine?: NewLineKind; 5911 noEmit?: boolean; 5912 /*@internal*/noEmitForJsFiles?: boolean; 5913 noEmitHelpers?: boolean; 5914 noEmitOnError?: boolean; 5915 noErrorTruncation?: boolean; 5916 noFallthroughCasesInSwitch?: boolean; 5917 noImplicitAny?: boolean; // Always combine with strict property 5918 noImplicitReturns?: boolean; 5919 noImplicitThis?: boolean; // Always combine with strict property 5920 noStrictGenericChecks?: boolean; 5921 noUnusedLocals?: boolean; 5922 noUnusedParameters?: boolean; 5923 noImplicitUseStrict?: boolean; 5924 noPropertyAccessFromIndexSignature?: boolean; 5925 assumeChangesOnlyAffectDirectDependencies?: boolean; 5926 noLib?: boolean; 5927 noResolve?: boolean; 5928 noUncheckedIndexedAccess?: boolean; 5929 out?: string; 5930 outDir?: string; 5931 outFile?: string; 5932 paths?: MapLike<string[]>; 5933 /** The directory of the config file that specified 'paths'. Used to resolve relative paths when 'baseUrl' is absent. */ 5934 /*@internal*/ pathsBasePath?: string; 5935 /*@internal*/ plugins?: PluginImport[]; 5936 preserveConstEnums?: boolean; 5937 preserveSymlinks?: boolean; 5938 /* @internal */ preserveWatchOutput?: boolean; 5939 project?: string; 5940 /* @internal */ pretty?: boolean; 5941 reactNamespace?: string; 5942 jsxFactory?: string; 5943 jsxFragmentFactory?: string; 5944 jsxImportSource?: string; 5945 composite?: boolean; 5946 incremental?: boolean; 5947 tsBuildInfoFile?: string; 5948 removeComments?: boolean; 5949 rootDir?: string; 5950 rootDirs?: string[]; 5951 skipLibCheck?: boolean; 5952 skipDefaultLibCheck?: boolean; 5953 sourceMap?: boolean; 5954 sourceRoot?: string; 5955 strict?: boolean; 5956 strictFunctionTypes?: boolean; // Always combine with strict property 5957 strictBindCallApply?: boolean; // Always combine with strict property 5958 strictNullChecks?: boolean; // Always combine with strict property 5959 strictPropertyInitialization?: boolean; // Always combine with strict property 5960 stripInternal?: boolean; 5961 suppressExcessPropertyErrors?: boolean; 5962 suppressImplicitAnyIndexErrors?: boolean; 5963 /* @internal */ suppressOutputPathCheck?: boolean; 5964 target?: ScriptTarget; // TODO: GH#18217 frequently asserted as defined 5965 traceResolution?: boolean; 5966 resolveJsonModule?: boolean; 5967 types?: string[]; 5968 /** Paths used to compute primary types search locations */ 5969 typeRoots?: string[]; 5970 /*@internal*/ version?: boolean; 5971 /*@internal*/ watch?: boolean; 5972 esModuleInterop?: boolean; 5973 /* @internal */ showConfig?: boolean; 5974 useDefineForClassFields?: boolean; 5975 ets?: EtsOptions; 5976 packageManagerType?: string; 5977 emitNodeModulesFiles?: boolean; 5978 etsLoaderPath?: string; 5979 [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; 5980 } 5981 5982 export interface EtsOptions { 5983 render: { method: string[]; decorator: string }; 5984 components: string[]; 5985 libs: string[]; 5986 extend: { 5987 decorator: string[]; 5988 components: { name: string; type: string; instance: string }[]; 5989 }; 5990 styles: { 5991 decorator: string; 5992 component: { name: string; type: string; instance: string }; 5993 property: string; 5994 }; 5995 concurrent: { 5996 decorator: string; 5997 }; 5998 customComponent?: string; 5999 propertyDecorators: { 6000 name: string; 6001 needInitialization: boolean; 6002 }[]; 6003 emitDecorators: { 6004 name: string, 6005 emitParameters: boolean 6006 }[]; 6007 } 6008 6009 export interface WatchOptions { 6010 watchFile?: WatchFileKind; 6011 watchDirectory?: WatchDirectoryKind; 6012 fallbackPolling?: PollingWatchKind; 6013 synchronousWatchDirectory?: boolean; 6014 excludeDirectories?: string[]; 6015 excludeFiles?: string[]; 6016 6017 [option: string]: CompilerOptionsValue | undefined; 6018 } 6019 6020 export interface TypeAcquisition { 6021 /** 6022 * @deprecated typingOptions.enableAutoDiscovery 6023 * Use typeAcquisition.enable instead. 6024 */ 6025 enableAutoDiscovery?: boolean; 6026 enable?: boolean; 6027 include?: string[]; 6028 exclude?: string[]; 6029 disableFilenameBasedTypeAcquisition?: boolean; 6030 [option: string]: CompilerOptionsValue | undefined; 6031 } 6032 6033 export enum ModuleKind { 6034 None = 0, 6035 CommonJS = 1, 6036 AMD = 2, 6037 UMD = 3, 6038 System = 4, 6039 6040 // NOTE: ES module kinds should be contiguous to more easily check whether a module kind is *any* ES module kind. 6041 // Non-ES module kinds should not come between ES2015 (the earliest ES module kind) and ESNext (the last ES 6042 // module kind). 6043 ES2015 = 5, 6044 ES2020 = 6, 6045 ESNext = 99 6046 } 6047 6048 export const enum JsxEmit { 6049 None = 0, 6050 Preserve = 1, 6051 React = 2, 6052 ReactNative = 3, 6053 ReactJSX = 4, 6054 ReactJSXDev = 5, 6055 } 6056 6057 export const enum ImportsNotUsedAsValues { 6058 Remove, 6059 Preserve, 6060 Error 6061 } 6062 6063 export const enum NewLineKind { 6064 CarriageReturnLineFeed = 0, 6065 LineFeed = 1 6066 } 6067 6068 export interface LineAndCharacter { 6069 /** 0-based. */ 6070 line: number; 6071 /* 6072 * 0-based. This value denotes the character position in line and is different from the 'column' because of tab characters. 6073 */ 6074 character: number; 6075 } 6076 6077 export const enum ScriptKind { 6078 Unknown = 0, 6079 JS = 1, 6080 JSX = 2, 6081 TS = 3, 6082 TSX = 4, 6083 External = 5, 6084 JSON = 6, 6085 /** 6086 * Used on extensions that doesn't define the ScriptKind but the content defines it. 6087 * Deferred extensions are going to be included in all project contexts. 6088 */ 6089 Deferred = 7, 6090 ETS = 8, 6091 } 6092 6093 export const enum ScriptTarget { 6094 ES3 = 0, 6095 ES5 = 1, 6096 ES2015 = 2, 6097 ES2016 = 3, 6098 ES2017 = 4, 6099 ES2018 = 5, 6100 ES2019 = 6, 6101 ES2020 = 7, 6102 ESNext = 99, 6103 JSON = 100, 6104 Latest = ESNext, 6105 } 6106 6107 export const enum LanguageVariant { 6108 Standard, 6109 JSX 6110 } 6111 6112 /** Either a parsed command line or a parsed tsconfig.json */ 6113 export interface ParsedCommandLine { 6114 options: CompilerOptions; 6115 typeAcquisition?: TypeAcquisition; 6116 fileNames: string[]; 6117 projectReferences?: readonly ProjectReference[]; 6118 watchOptions?: WatchOptions; 6119 raw?: any; 6120 errors: Diagnostic[]; 6121 wildcardDirectories?: MapLike<WatchDirectoryFlags>; 6122 compileOnSave?: boolean; 6123 } 6124 6125 export const enum WatchDirectoryFlags { 6126 None = 0, 6127 Recursive = 1 << 0, 6128 } 6129 6130 /* @internal */ 6131 export interface ConfigFileSpecs { 6132 filesSpecs: readonly string[] | undefined; 6133 /** 6134 * Present to report errors (user specified specs), validatedIncludeSpecs are used for file name matching 6135 */ 6136 includeSpecs: readonly string[] | undefined; 6137 /** 6138 * Present to report errors (user specified specs), validatedExcludeSpecs are used for file name matching 6139 */ 6140 excludeSpecs: readonly string[] | undefined; 6141 validatedFilesSpec: readonly string[] | undefined; 6142 validatedIncludeSpecs: readonly string[] | undefined; 6143 validatedExcludeSpecs: readonly string[] | undefined; 6144 } 6145 6146 /* @internal */ 6147 export type RequireResult<T = {}> = 6148 | { module: T, modulePath?: string, error: undefined } 6149 | { module: undefined, modulePath?: undefined, error: { stack?: string, message?: string } }; 6150 6151 export interface CreateProgramOptions { 6152 rootNames: readonly string[]; 6153 options: CompilerOptions; 6154 projectReferences?: readonly ProjectReference[]; 6155 host?: CompilerHost; 6156 oldProgram?: Program; 6157 configFileParsingDiagnostics?: readonly Diagnostic[]; 6158 } 6159 6160 /* @internal */ 6161 export interface CommandLineOptionBase { 6162 name: string; 6163 type: "string" | "number" | "boolean" | "object" | "list" | ESMap<string, number | string>; // a value of a primitive type, or an object literal mapping named values to actual values 6164 isFilePath?: boolean; // True if option value is a path or fileName 6165 shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' 6166 description?: DiagnosticMessage; // The message describing what the command line switch does 6167 paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter 6168 isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file 6169 isCommandLineOnly?: boolean; 6170 showInSimplifiedHelpView?: boolean; 6171 category?: DiagnosticMessage; 6172 strictFlag?: true; // true if the option is one of the flag under strict 6173 affectsSourceFile?: true; // true if we should recreate SourceFiles after this option changes 6174 affectsModuleResolution?: true; // currently same effect as `affectsSourceFile` 6175 affectsBindDiagnostics?: true; // true if this affects binding (currently same effect as `affectsSourceFile`) 6176 affectsSemanticDiagnostics?: true; // true if option affects semantic diagnostics 6177 affectsEmit?: true; // true if the options affects emit 6178 transpileOptionValue?: boolean | undefined; // If set this means that the option should be set to this value when transpiling 6179 extraValidation?: (value: CompilerOptionsValue) => [DiagnosticMessage, ...string[]] | undefined; // Additional validation to be performed for the value to be valid 6180 } 6181 6182 /* @internal */ 6183 export interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase { 6184 type: "string" | "number" | "boolean"; 6185 } 6186 6187 /* @internal */ 6188 export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { 6189 type: ESMap<string, number | string>; // an object literal mapping named values to actual values 6190 } 6191 6192 /* @internal */ 6193 export interface DidYouMeanOptionsDiagnostics { 6194 optionDeclarations: CommandLineOption[]; 6195 unknownOptionDiagnostic: DiagnosticMessage, 6196 unknownDidYouMeanDiagnostic: DiagnosticMessage, 6197 } 6198 6199 /* @internal */ 6200 export interface TsConfigOnlyOption extends CommandLineOptionBase { 6201 type: "object"; 6202 elementOptions?: ESMap<string, CommandLineOption>; 6203 extraKeyDiagnostics?: DidYouMeanOptionsDiagnostics; 6204 } 6205 6206 /* @internal */ 6207 export interface CommandLineOptionOfListType extends CommandLineOptionBase { 6208 type: "list"; 6209 element: CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption; 6210 } 6211 6212 /* @internal */ 6213 export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType | TsConfigOnlyOption | CommandLineOptionOfListType; 6214 6215 /* @internal */ 6216 export const enum CharacterCodes { 6217 nullCharacter = 0, 6218 maxAsciiCharacter = 0x7F, 6219 6220 lineFeed = 0x0A, // \n 6221 carriageReturn = 0x0D, // \r 6222 lineSeparator = 0x2028, 6223 paragraphSeparator = 0x2029, 6224 nextLine = 0x0085, 6225 6226 // Unicode 3.0 space characters 6227 space = 0x0020, // " " 6228 nonBreakingSpace = 0x00A0, // 6229 enQuad = 0x2000, 6230 emQuad = 0x2001, 6231 enSpace = 0x2002, 6232 emSpace = 0x2003, 6233 threePerEmSpace = 0x2004, 6234 fourPerEmSpace = 0x2005, 6235 sixPerEmSpace = 0x2006, 6236 figureSpace = 0x2007, 6237 punctuationSpace = 0x2008, 6238 thinSpace = 0x2009, 6239 hairSpace = 0x200A, 6240 zeroWidthSpace = 0x200B, 6241 narrowNoBreakSpace = 0x202F, 6242 ideographicSpace = 0x3000, 6243 mathematicalSpace = 0x205F, 6244 ogham = 0x1680, 6245 6246 _ = 0x5F, 6247 $ = 0x24, 6248 6249 _0 = 0x30, 6250 _1 = 0x31, 6251 _2 = 0x32, 6252 _3 = 0x33, 6253 _4 = 0x34, 6254 _5 = 0x35, 6255 _6 = 0x36, 6256 _7 = 0x37, 6257 _8 = 0x38, 6258 _9 = 0x39, 6259 6260 a = 0x61, 6261 b = 0x62, 6262 c = 0x63, 6263 d = 0x64, 6264 e = 0x65, 6265 f = 0x66, 6266 g = 0x67, 6267 h = 0x68, 6268 i = 0x69, 6269 j = 0x6A, 6270 k = 0x6B, 6271 l = 0x6C, 6272 m = 0x6D, 6273 n = 0x6E, 6274 o = 0x6F, 6275 p = 0x70, 6276 q = 0x71, 6277 r = 0x72, 6278 s = 0x73, 6279 t = 0x74, 6280 u = 0x75, 6281 v = 0x76, 6282 w = 0x77, 6283 x = 0x78, 6284 y = 0x79, 6285 z = 0x7A, 6286 6287 A = 0x41, 6288 B = 0x42, 6289 C = 0x43, 6290 D = 0x44, 6291 E = 0x45, 6292 F = 0x46, 6293 G = 0x47, 6294 H = 0x48, 6295 I = 0x49, 6296 J = 0x4A, 6297 K = 0x4B, 6298 L = 0x4C, 6299 M = 0x4D, 6300 N = 0x4E, 6301 O = 0x4F, 6302 P = 0x50, 6303 Q = 0x51, 6304 R = 0x52, 6305 S = 0x53, 6306 T = 0x54, 6307 U = 0x55, 6308 V = 0x56, 6309 W = 0x57, 6310 X = 0x58, 6311 Y = 0x59, 6312 Z = 0x5a, 6313 6314 ampersand = 0x26, // & 6315 asterisk = 0x2A, // * 6316 at = 0x40, // @ 6317 backslash = 0x5C, // \ 6318 backtick = 0x60, // ` 6319 bar = 0x7C, // | 6320 caret = 0x5E, // ^ 6321 closeBrace = 0x7D, // } 6322 closeBracket = 0x5D, // ] 6323 closeParen = 0x29, // ) 6324 colon = 0x3A, // : 6325 comma = 0x2C, // , 6326 dot = 0x2E, // . 6327 doubleQuote = 0x22, // " 6328 equals = 0x3D, // = 6329 exclamation = 0x21, // ! 6330 greaterThan = 0x3E, // > 6331 hash = 0x23, // # 6332 lessThan = 0x3C, // < 6333 minus = 0x2D, // - 6334 openBrace = 0x7B, // { 6335 openBracket = 0x5B, // [ 6336 openParen = 0x28, // ( 6337 percent = 0x25, // % 6338 plus = 0x2B, // + 6339 question = 0x3F, // ? 6340 semicolon = 0x3B, // ; 6341 singleQuote = 0x27, // ' 6342 slash = 0x2F, // / 6343 tilde = 0x7E, // ~ 6344 6345 backspace = 0x08, // \b 6346 formFeed = 0x0C, // \f 6347 byteOrderMark = 0xFEFF, 6348 tab = 0x09, // \t 6349 verticalTab = 0x0B, // \v 6350 } 6351 6352 export interface ModuleResolutionHost { 6353 // TODO: GH#18217 Optional methods frequently used as non-optional 6354 6355 fileExists(fileName: string): boolean; 6356 // readFile function is used to read arbitrary text files on disk, i.e. when resolution procedure needs the content of 'package.json' 6357 // to determine location of bundled typings for node module 6358 readFile(fileName: string): string | undefined; 6359 trace?(s: string): void; 6360 directoryExists?(directoryName: string): boolean; 6361 /** 6362 * Resolve a symbolic link. 6363 * @see https://nodejs.org/api/fs.html#fs_fs_realpathsync_path_options 6364 */ 6365 realpath?(path: string): string; 6366 getCurrentDirectory?(): string; 6367 getDirectories?(path: string): string[]; 6368 /** 6369 * get tagName where need to be determined based on the file path 6370 * @param filePath filePath 6371 */ 6372 getTagNameNeededCheckByFile?(containFilePath: string, sourceFilePath: string): TagCheckParam; 6373 /** 6374 * get checked results based on the file path and jsDocs 6375 * @param filePath string 6376 * @param jsDoc JSDoc[] 6377 */ 6378 getExpressionCheckedResultsByFile?(filePath: string, jsDocs: JSDocTagInfo[]): ConditionCheckResult; 6379 } 6380 6381 /** 6382 * Represents the result of module resolution. 6383 * Module resolution will pick up tsx/jsx/js files even if '--jsx' and '--allowJs' are turned off. 6384 * The Program will then filter results based on these flags. 6385 * 6386 * Prefer to return a `ResolvedModuleFull` so that the file type does not have to be inferred. 6387 */ 6388 export interface ResolvedModule { 6389 /** Path of the file the module was resolved to. */ 6390 resolvedFileName: string; 6391 /** True if `resolvedFileName` comes from `node_modules`. */ 6392 isExternalLibraryImport?: boolean; 6393 } 6394 6395 /** 6396 * ResolvedModule with an explicitly provided `extension` property. 6397 * Prefer this over `ResolvedModule`. 6398 * If changing this, remember to change `moduleResolutionIsEqualTo`. 6399 */ 6400 export interface ResolvedModuleFull extends ResolvedModule { 6401 /* @internal */ 6402 readonly originalPath?: string; 6403 /** 6404 * Extension of resolvedFileName. This must match what's at the end of resolvedFileName. 6405 * This is optional for backwards-compatibility, but will be added if not provided. 6406 */ 6407 extension: Extension; 6408 packageId?: PackageId; 6409 } 6410 6411 /** 6412 * Unique identifier with a package name and version. 6413 * If changing this, remember to change `packageIdIsEqual`. 6414 */ 6415 export interface PackageId { 6416 /** 6417 * Name of the package. 6418 * Should not include `@types`. 6419 * If accessing a non-index file, this should include its name e.g. "foo/bar". 6420 */ 6421 name: string; 6422 /** 6423 * Name of a submodule within this package. 6424 * May be "". 6425 */ 6426 subModuleName: string; 6427 /** Version of the package, e.g. "1.2.3" */ 6428 version: string; 6429 } 6430 6431 export const enum Extension { 6432 Ts = ".ts", 6433 Tsx = ".tsx", 6434 Dts = ".d.ts", 6435 Js = ".js", 6436 Jsx = ".jsx", 6437 Json = ".json", 6438 TsBuildInfo = ".tsbuildinfo", 6439 Ets = ".ets", 6440 Dets = ".d.ets" 6441 } 6442 6443 export interface ResolvedModuleWithFailedLookupLocations { 6444 readonly resolvedModule: ResolvedModuleFull | undefined; 6445 /* @internal */ 6446 readonly failedLookupLocations: string[]; 6447 } 6448 6449 export interface ResolvedTypeReferenceDirective { 6450 // True if the type declaration file was found in a primary lookup location 6451 primary: boolean; 6452 // The location of the .d.ts file we located, or undefined if resolution failed 6453 resolvedFileName: string | undefined; 6454 packageId?: PackageId; 6455 /** True if `resolvedFileName` comes from `node_modules` or `oh_modules`. */ 6456 isExternalLibraryImport?: boolean; 6457 } 6458 6459 export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { 6460 readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; 6461 readonly failedLookupLocations: string[]; 6462 } 6463 6464 /* @internal */ 6465 export type HasInvalidatedResolution = (sourceFile: Path) => boolean; 6466 /* @internal */ 6467 export type HasChangedAutomaticTypeDirectiveNames = () => boolean; 6468 6469 export interface TagCheckParam { 6470 needCheck: boolean; 6471 checkConfig: TagCheckConfig[]; 6472 } 6473 export interface TagCheckConfig { 6474 tagName: string; 6475 message: string; 6476 needConditionCheck: boolean; 6477 type: DiagnosticCategory; 6478 specifyCheckConditionFuncName: string; 6479 tagNameShouldExisted: boolean; 6480 } 6481 export interface ConditionCheckResult { 6482 valid: boolean; 6483 } 6484 export interface CompilerHost extends ModuleResolutionHost { 6485 getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; 6486 getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; 6487 getCancellationToken?(): CancellationToken; 6488 getDefaultLibFileName(options: CompilerOptions): string; 6489 getDefaultLibLocation?(): string; 6490 writeFile: WriteFileCallback; 6491 getCurrentDirectory(): string; 6492 getCanonicalFileName(fileName: string): string; 6493 useCaseSensitiveFileNames(): boolean; 6494 getNewLine(): string; 6495 readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; 6496 6497 /* 6498 * CompilerHost must either implement resolveModuleNames (in case if it wants to be completely in charge of 6499 * module name resolution) or provide implementation for methods from ModuleResolutionHost (in this case compiler 6500 * will apply built-in module resolution logic and use members of ModuleResolutionHost to ask host specific questions). 6501 * If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just 6502 * 'throw new Error("NotImplemented")' 6503 */ 6504 resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; 6505 /** 6506 * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files 6507 */ 6508 resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; 6509 getEnvironmentVariable?(name: string): string | undefined; 6510 /* @internal */ onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean): void; 6511 /* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution; 6512 /* @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames; 6513 createHash?(data: string): string; 6514 getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; 6515 /* @internal */ useSourceOfProjectReferenceRedirect?(): boolean; 6516 6517 // TODO: later handle this in better way in builder host instead once the api for tsbuild finalizes and doesn't use compilerHost as base 6518 /*@internal*/createDirectory?(directory: string): void; 6519 /*@internal*/getSymlinkCache?(): SymlinkCache; 6520 /** 6521 * get tagName where need to be determined based on the file path 6522 * @param filePath filePath 6523 */ 6524 getTagNameNeededCheckByFile?(containFilePath: string, sourceFilePath: string): TagCheckParam; 6525 /** 6526 * get checked results based on the file path and jsDocs 6527 * @param filePath string 6528 * @param jsDoc JSDoc[] 6529 */ 6530 getExpressionCheckedResultsByFile?(filePath: string, jsDocs: JSDocTagInfo[]): ConditionCheckResult; 6531 } 6532 6533 /** true if --out otherwise source file name */ 6534 /*@internal*/ 6535 export type SourceOfProjectReferenceRedirect = string | true; 6536 6537 /*@internal*/ 6538 export interface ResolvedProjectReferenceCallbacks { 6539 getSourceOfProjectReferenceRedirect(fileName: string): SourceOfProjectReferenceRedirect | undefined; 6540 forEachResolvedProjectReference<T>(cb: (resolvedProjectReference: ResolvedProjectReference) => T | undefined): T | undefined; 6541 } 6542 6543 /* @internal */ 6544 export const enum TransformFlags { 6545 None = 0, 6546 6547 // Facts 6548 // - Flags used to indicate that a node or subtree contains syntax that requires transformation. 6549 ContainsTypeScript = 1 << 0, 6550 ContainsJsx = 1 << 1, 6551 ContainsESNext = 1 << 2, 6552 ContainsES2020 = 1 << 3, 6553 ContainsES2019 = 1 << 4, 6554 ContainsES2018 = 1 << 5, 6555 ContainsES2017 = 1 << 6, 6556 ContainsES2016 = 1 << 7, 6557 ContainsES2015 = 1 << 8, 6558 ContainsGenerator = 1 << 9, 6559 ContainsDestructuringAssignment = 1 << 10, 6560 6561 // Markers 6562 // - Flags used to indicate that a subtree contains a specific transformation. 6563 ContainsTypeScriptClassSyntax = 1 << 11, // Decorators, Property Initializers, Parameter Property Initializers 6564 ContainsLexicalThis = 1 << 12, 6565 ContainsRestOrSpread = 1 << 13, 6566 ContainsObjectRestOrSpread = 1 << 14, 6567 ContainsComputedPropertyName = 1 << 15, 6568 ContainsBlockScopedBinding = 1 << 16, 6569 ContainsBindingPattern = 1 << 17, 6570 ContainsYield = 1 << 18, 6571 ContainsAwait = 1 << 19, 6572 ContainsHoistedDeclarationOrCompletion = 1 << 20, 6573 ContainsDynamicImport = 1 << 21, 6574 ContainsClassFields = 1 << 22, 6575 ContainsPossibleTopLevelAwait = 1 << 23, 6576 6577 // Please leave this as 1 << 29. 6578 // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. 6579 // It is a good reminder of how much room we have left 6580 HasComputedFlags = 1 << 29, // Transform flags have been computed. 6581 6582 // Assertions 6583 // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. 6584 AssertTypeScript = ContainsTypeScript, 6585 AssertJsx = ContainsJsx, 6586 AssertESNext = ContainsESNext, 6587 AssertES2020 = ContainsES2020, 6588 AssertES2019 = ContainsES2019, 6589 AssertES2018 = ContainsES2018, 6590 AssertES2017 = ContainsES2017, 6591 AssertES2016 = ContainsES2016, 6592 AssertES2015 = ContainsES2015, 6593 AssertGenerator = ContainsGenerator, 6594 AssertDestructuringAssignment = ContainsDestructuringAssignment, 6595 6596 // Scope Exclusions 6597 // - Bitmasks that exclude flags from propagating out of a specific context 6598 // into the subtree flags of their container. 6599 OuterExpressionExcludes = HasComputedFlags, 6600 PropertyAccessExcludes = OuterExpressionExcludes, 6601 NodeExcludes = PropertyAccessExcludes, 6602 ArrowFunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait, 6603 FunctionExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait, 6604 ConstructorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread | ContainsPossibleTopLevelAwait, 6605 MethodOrAccessorExcludes = NodeExcludes | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsYield | ContainsAwait | ContainsHoistedDeclarationOrCompletion | ContainsBindingPattern | ContainsObjectRestOrSpread, 6606 PropertyExcludes = NodeExcludes | ContainsLexicalThis, 6607 ClassExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName, 6608 ModuleExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsLexicalThis | ContainsBlockScopedBinding | ContainsHoistedDeclarationOrCompletion | ContainsPossibleTopLevelAwait, 6609 TypeExcludes = ~ContainsTypeScript, 6610 ObjectLiteralExcludes = NodeExcludes | ContainsTypeScriptClassSyntax | ContainsComputedPropertyName | ContainsObjectRestOrSpread, 6611 ArrayLiteralOrCallOrNewExcludes = NodeExcludes | ContainsRestOrSpread, 6612 VariableDeclarationListExcludes = NodeExcludes | ContainsBindingPattern | ContainsObjectRestOrSpread, 6613 ParameterExcludes = NodeExcludes, 6614 CatchClauseExcludes = NodeExcludes | ContainsObjectRestOrSpread, 6615 BindingPatternExcludes = NodeExcludes | ContainsRestOrSpread, 6616 6617 // Propagating flags 6618 // - Bitmasks for flags that should propagate from a child 6619 PropertyNamePropagatingFlags = ContainsLexicalThis, 6620 6621 // Masks 6622 // - Additional bitmasks 6623 } 6624 6625 export interface SourceMapRange extends TextRange { 6626 source?: SourceMapSource; 6627 } 6628 6629 export interface SourceMapSource { 6630 fileName: string; 6631 text: string; 6632 /* @internal */ lineMap: readonly number[]; 6633 skipTrivia?: (pos: number) => number; 6634 } 6635 6636 /* @internal */ 6637 export interface EmitNode { 6638 annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup. 6639 flags: EmitFlags; // Flags that customize emit 6640 leadingComments?: SynthesizedComment[]; // Synthesized leading comments 6641 trailingComments?: SynthesizedComment[]; // Synthesized trailing comments 6642 commentRange?: TextRange; // The text range to use when emitting leading or trailing comments 6643 sourceMapRange?: SourceMapRange; // The text range to use when emitting leading or trailing source mappings 6644 tokenSourceMapRanges?: (SourceMapRange | undefined)[]; // The text range to use when emitting source mappings for tokens 6645 constantValue?: string | number; // The constant value of an expression 6646 externalHelpersModuleName?: Identifier; // The local name for an imported helpers module 6647 externalHelpers?: boolean; 6648 helpers?: EmitHelper[]; // Emit helpers for the node 6649 startsOnNewLine?: boolean; // If the node should begin on a new line 6650 } 6651 6652 export const enum EmitFlags { 6653 None = 0, 6654 SingleLine = 1 << 0, // The contents of this node should be emitted on a single line. 6655 AdviseOnEmitNode = 1 << 1, // The printer should invoke the onEmitNode callback when printing this node. 6656 NoSubstitution = 1 << 2, // Disables further substitution of an expression. 6657 CapturesThis = 1 << 3, // The function captures a lexical `this` 6658 NoLeadingSourceMap = 1 << 4, // Do not emit a leading source map location for this node. 6659 NoTrailingSourceMap = 1 << 5, // Do not emit a trailing source map location for this node. 6660 NoSourceMap = NoLeadingSourceMap | NoTrailingSourceMap, // Do not emit a source map location for this node. 6661 NoNestedSourceMaps = 1 << 6, // Do not emit source map locations for children of this node. 6662 NoTokenLeadingSourceMaps = 1 << 7, // Do not emit leading source map location for token nodes. 6663 NoTokenTrailingSourceMaps = 1 << 8, // Do not emit trailing source map location for token nodes. 6664 NoTokenSourceMaps = NoTokenLeadingSourceMaps | NoTokenTrailingSourceMaps, // Do not emit source map locations for tokens of this node. 6665 NoLeadingComments = 1 << 9, // Do not emit leading comments for this node. 6666 NoTrailingComments = 1 << 10, // Do not emit trailing comments for this node. 6667 NoComments = NoLeadingComments | NoTrailingComments, // Do not emit comments for this node. 6668 NoNestedComments = 1 << 11, 6669 HelperName = 1 << 12, // The Identifier refers to an *unscoped* emit helper (one that is emitted at the top of the file) 6670 ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). 6671 LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration. 6672 InternalName = 1 << 15, // The name is internal to an ES5 class body function. 6673 Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). 6674 NoIndentation = 1 << 17, // Do not indent the node. 6675 AsyncFunctionBody = 1 << 18, 6676 ReuseTempVariableScope = 1 << 19, // Reuse the existing temp variable scope during emit. 6677 CustomPrologue = 1 << 20, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed). 6678 NoHoisting = 1 << 21, // Do not hoist this declaration in --module system 6679 HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration 6680 Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable. 6681 NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions. 6682 /*@internal*/ TypeScriptClassWrapper = 1 << 25, // The node is an IIFE class wrapper created by the ts transform. 6683 /*@internal*/ NeverApplyImportHelper = 1 << 26, // Indicates the node should never be wrapped with an import star helper (because, for example, it imports tslib itself) 6684 /*@internal*/ IgnoreSourceNewlines = 1 << 27, // Overrides `printerOptions.preserveSourceNewlines` to print this node (and all descendants) with default whitespace. 6685 } 6686 6687 export interface EmitHelper { 6688 readonly name: string; // A unique name for this helper. 6689 readonly scoped: boolean; // Indicates whether the helper MUST be emitted in the current scope. 6690 readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); // ES3-compatible raw script text, or a function yielding such a string 6691 readonly priority?: number; // Helpers with a higher priority are emitted earlier than other helpers on the node. 6692 readonly dependencies?: EmitHelper[] 6693 } 6694 6695 export interface UnscopedEmitHelper extends EmitHelper { 6696 readonly scoped: false; // Indicates whether the helper MUST be emitted in the current scope. 6697 /* @internal */ 6698 readonly importName?: string; // The name of the helper to use when importing via `--importHelpers`. 6699 readonly text: string; // ES3-compatible raw script text, or a function yielding such a string 6700 } 6701 6702 /* @internal */ 6703 export type UniqueNameHandler = (baseName: string, checkFn?: (name: string) => boolean, optimistic?: boolean) => string; 6704 6705 export type EmitHelperUniqueNameCallback = (name: string) => string; 6706 6707 /** 6708 * Used by the checker, this enum keeps track of external emit helpers that should be type 6709 * checked. 6710 */ 6711 /* @internal */ 6712 export const enum ExternalEmitHelpers { 6713 Extends = 1 << 0, // __extends (used by the ES2015 class transformation) 6714 Assign = 1 << 1, // __assign (used by Jsx and ESNext object spread transformations) 6715 Rest = 1 << 2, // __rest (used by ESNext object rest transformation) 6716 Decorate = 1 << 3, // __decorate (used by TypeScript decorators transformation) 6717 Metadata = 1 << 4, // __metadata (used by TypeScript decorators transformation) 6718 Param = 1 << 5, // __param (used by TypeScript decorators transformation) 6719 Awaiter = 1 << 6, // __awaiter (used by ES2017 async functions transformation) 6720 Generator = 1 << 7, // __generator (used by ES2015 generator transformation) 6721 Values = 1 << 8, // __values (used by ES2015 for..of and yield* transformations) 6722 Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation) 6723 SpreadArray = 1 << 10, // __spreadArray (used by ES2015 array spread and argument list spread transformations) 6724 Await = 1 << 11, // __await (used by ES2017 async generator transformation) 6725 AsyncGenerator = 1 << 12, // __asyncGenerator (used by ES2017 async generator transformation) 6726 AsyncDelegator = 1 << 13, // __asyncDelegator (used by ES2017 async generator yield* transformation) 6727 AsyncValues = 1 << 14, // __asyncValues (used by ES2017 for..await..of transformation) 6728 ExportStar = 1 << 15, // __exportStar (used by CommonJS/AMD/UMD module transformation) 6729 ImportStar = 1 << 16, // __importStar (used by CommonJS/AMD/UMD module transformation) 6730 ImportDefault = 1 << 17, // __importStar (used by CommonJS/AMD/UMD module transformation) 6731 MakeTemplateObject = 1 << 18, // __makeTemplateObject (used for constructing template string array objects) 6732 ClassPrivateFieldGet = 1 << 19, // __classPrivateFieldGet (used by the class private field transformation) 6733 ClassPrivateFieldSet = 1 << 20, // __classPrivateFieldSet (used by the class private field transformation) 6734 CreateBinding = 1 << 21, // __createBinding (use by the module transform for (re)exports and namespace imports) 6735 FirstEmitHelper = Extends, 6736 LastEmitHelper = CreateBinding, 6737 6738 // Helpers included by ES2015 for..of 6739 ForOfIncludes = Values, 6740 6741 // Helpers included by ES2017 for..await..of 6742 ForAwaitOfIncludes = AsyncValues, 6743 6744 // Helpers included by ES2017 async generators 6745 AsyncGeneratorIncludes = Await | AsyncGenerator, 6746 6747 // Helpers included by yield* in ES2017 async generators 6748 AsyncDelegatorIncludes = Await | AsyncDelegator | AsyncValues, 6749 6750 // Helpers included by ES2015 spread 6751 SpreadIncludes = Read | SpreadArray, 6752 } 6753 6754 export const enum EmitHint { 6755 SourceFile, // Emitting a SourceFile 6756 Expression, // Emitting an Expression 6757 IdentifierName, // Emitting an IdentifierName 6758 MappedTypeParameter, // Emitting a TypeParameterDeclaration inside of a MappedTypeNode 6759 Unspecified, // Emitting an otherwise unspecified node 6760 EmbeddedStatement, // Emitting an embedded statement 6761 JsxAttributeValue, // Emitting a JSX attribute value 6762 } 6763 6764 export interface SourceFileMayBeEmittedHost { 6765 getCompilerOptions(): CompilerOptions; 6766 isSourceFileFromExternalLibrary(file: SourceFile): boolean; 6767 getResolvedProjectReferenceToRedirect(fileName: string): ResolvedProjectReference | undefined; 6768 isSourceOfProjectReferenceRedirect(fileName: string): boolean; 6769 } 6770 6771 export interface EmitHost extends ScriptReferenceHost, ModuleSpecifierResolutionHost, SourceFileMayBeEmittedHost { 6772 getSourceFiles(): readonly SourceFile[]; 6773 useCaseSensitiveFileNames(): boolean; 6774 getCurrentDirectory(): string; 6775 6776 getLibFileFromReference(ref: FileReference): SourceFile | undefined; 6777 6778 getCommonSourceDirectory(): string; 6779 getCanonicalFileName(fileName: string): string; 6780 getNewLine(): string; 6781 6782 isEmitBlocked(emitFileName: string): boolean; 6783 6784 getPrependNodes(): readonly (InputFiles | UnparsedSource)[]; 6785 6786 writeFile: WriteFileCallback; 6787 /* @internal */ 6788 getProgramBuildInfo(): ProgramBuildInfo | undefined; 6789 getSourceFileFromReference: Program["getSourceFileFromReference"]; 6790 readonly redirectTargetsMap: RedirectTargetsMap; 6791 } 6792 6793 /* @internal */ 6794 export interface PropertyDescriptorAttributes { 6795 enumerable?: boolean | Expression; 6796 configurable?: boolean | Expression; 6797 writable?: boolean | Expression; 6798 value?: Expression; 6799 get?: Expression; 6800 set?: Expression; 6801 } 6802 6803 export const enum OuterExpressionKinds { 6804 Parentheses = 1 << 0, 6805 TypeAssertions = 1 << 1, 6806 NonNullAssertions = 1 << 2, 6807 PartiallyEmittedExpressions = 1 << 3, 6808 6809 Assertions = TypeAssertions | NonNullAssertions, 6810 All = Parentheses | Assertions | PartiallyEmittedExpressions 6811 } 6812 6813 /* @internal */ 6814 export type OuterExpression = 6815 | ParenthesizedExpression 6816 | TypeAssertion 6817 | AsExpression 6818 | NonNullExpression 6819 | PartiallyEmittedExpression; 6820 6821 export type TypeOfTag = "undefined" | "number" | "bigint" | "boolean" | "string" | "symbol" | "object" | "function"; 6822 6823 /* @internal */ 6824 export interface CallBinding { 6825 target: LeftHandSideExpression; 6826 thisArg: Expression; 6827 } 6828 6829 /* @internal */ 6830 export interface ParenthesizerRules { 6831 parenthesizeLeftSideOfBinary(binaryOperator: SyntaxKind, leftSide: Expression): Expression; 6832 parenthesizeRightSideOfBinary(binaryOperator: SyntaxKind, leftSide: Expression | undefined, rightSide: Expression): Expression; 6833 parenthesizeExpressionOfComputedPropertyName(expression: Expression): Expression; 6834 parenthesizeConditionOfConditionalExpression(condition: Expression): Expression; 6835 parenthesizeBranchOfConditionalExpression(branch: Expression): Expression; 6836 parenthesizeExpressionOfExportDefault(expression: Expression): Expression; 6837 parenthesizeExpressionOfNew(expression: Expression): LeftHandSideExpression; 6838 parenthesizeLeftSideOfAccess(expression: Expression): LeftHandSideExpression; 6839 parenthesizeOperandOfPostfixUnary(operand: Expression): LeftHandSideExpression; 6840 parenthesizeOperandOfPrefixUnary(operand: Expression): UnaryExpression; 6841 parenthesizeExpressionsOfCommaDelimitedList(elements: readonly Expression[]): NodeArray<Expression>; 6842 parenthesizeExpressionForDisallowedComma(expression: Expression): Expression; 6843 parenthesizeExpressionOfExpressionStatement(expression: Expression): Expression; 6844 parenthesizeConciseBodyOfArrowFunction(body: ConciseBody): ConciseBody; 6845 parenthesizeMemberOfConditionalType(member: TypeNode): TypeNode; 6846 parenthesizeMemberOfElementType(member: TypeNode): TypeNode; 6847 parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode; 6848 parenthesizeConstituentTypesOfUnionOrIntersectionType(members: readonly TypeNode[]): NodeArray<TypeNode>; 6849 parenthesizeTypeArguments(typeParameters: readonly TypeNode[] | undefined): NodeArray<TypeNode> | undefined; 6850 } 6851 6852 /* @internal */ 6853 export interface NodeConverters { 6854 convertToFunctionBlock(node: ConciseBody, multiLine?: boolean): Block; 6855 convertToFunctionExpression(node: FunctionDeclaration): FunctionExpression; 6856 convertToArrayAssignmentElement(element: ArrayBindingOrAssignmentElement): Expression; 6857 convertToObjectAssignmentElement(element: ObjectBindingOrAssignmentElement): ObjectLiteralElementLike; 6858 convertToAssignmentPattern(node: BindingOrAssignmentPattern): AssignmentPattern; 6859 convertToObjectAssignmentPattern(node: ObjectBindingOrAssignmentPattern): ObjectLiteralExpression; 6860 convertToArrayAssignmentPattern(node: ArrayBindingOrAssignmentPattern): ArrayLiteralExpression; 6861 convertToAssignmentElementTarget(node: BindingOrAssignmentElementTarget): Expression; 6862 } 6863 6864 export interface NodeFactory { 6865 /* @internal */ readonly parenthesizer: ParenthesizerRules; 6866 /* @internal */ readonly converters: NodeConverters; 6867 createNodeArray<T extends Node>(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray<T>; 6868 6869 // 6870 // Literals 6871 // 6872 6873 createNumericLiteral(value: string | number, numericLiteralFlags?: TokenFlags): NumericLiteral; 6874 createBigIntLiteral(value: string | PseudoBigInt): BigIntLiteral; 6875 createStringLiteral(text: string, isSingleQuote?: boolean): StringLiteral; 6876 /* @internal*/ createStringLiteral(text: string, isSingleQuote?: boolean, hasExtendedUnicodeEscape?: boolean): StringLiteral; // eslint-disable-line @typescript-eslint/unified-signatures 6877 createStringLiteralFromNode(sourceNode: PropertyNameLiteral, isSingleQuote?: boolean): StringLiteral; 6878 createRegularExpressionLiteral(text: string): RegularExpressionLiteral; 6879 6880 // 6881 // Identifiers 6882 // 6883 6884 createIdentifier(text: string): Identifier; 6885 /* @internal */ createIdentifier(text: string, typeArguments?: readonly (TypeNode | TypeParameterDeclaration)[], originalKeywordKind?: SyntaxKind): Identifier; // eslint-disable-line @typescript-eslint/unified-signatures 6886 /* @internal */ updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode | TypeParameterDeclaration> | undefined): Identifier; 6887 6888 /** Create a unique temporary variable. */ 6889 createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; 6890 /* @internal */ createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): Identifier; // eslint-disable-line @typescript-eslint/unified-signatures 6891 6892 /** Create a unique temporary variable for use in a loop. */ 6893 createLoopVariable(): Identifier; 6894 6895 /** Create a unique name based on the supplied text. */ 6896 createUniqueName(text: string, flags?: GeneratedIdentifierFlags): Identifier; 6897 6898 /** Create a unique name generated for a node. */ 6899 getGeneratedNameForNode(node: Node | undefined): Identifier; 6900 /* @internal */ getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier; // eslint-disable-line @typescript-eslint/unified-signatures 6901 6902 createPrivateIdentifier(text: string): PrivateIdentifier 6903 6904 // 6905 // Punctuation 6906 // 6907 6908 createToken(token: SyntaxKind.SuperKeyword): SuperExpression; 6909 createToken(token: SyntaxKind.ThisKeyword): ThisExpression; 6910 createToken(token: SyntaxKind.NullKeyword): NullLiteral; 6911 createToken(token: SyntaxKind.TrueKeyword): TrueLiteral; 6912 createToken(token: SyntaxKind.FalseKeyword): FalseLiteral; 6913 createToken<TKind extends PunctuationSyntaxKind>(token: TKind): PunctuationToken<TKind>; 6914 createToken<TKind extends KeywordTypeSyntaxKind>(token: TKind): KeywordTypeNode<TKind>; 6915 createToken<TKind extends ModifierSyntaxKind>(token: TKind): ModifierToken<TKind>; 6916 createToken<TKind extends KeywordSyntaxKind>(token: TKind): KeywordToken<TKind>; 6917 createToken<TKind extends SyntaxKind.Unknown | SyntaxKind.EndOfFileToken>(token: TKind): Token<TKind>; 6918 /*@internal*/ createToken<TKind extends SyntaxKind>(token: TKind): Token<TKind>; 6919 6920 // 6921 // Reserved words 6922 // 6923 6924 createSuper(): SuperExpression; 6925 createThis(): ThisExpression; 6926 createNull(): NullLiteral; 6927 createTrue(): TrueLiteral; 6928 createFalse(): FalseLiteral; 6929 6930 // 6931 // Modifiers 6932 // 6933 6934 createModifier<T extends ModifierSyntaxKind>(kind: T): ModifierToken<T>; 6935 createModifiersFromModifierFlags(flags: ModifierFlags): Modifier[]; 6936 6937 // 6938 // Names 6939 // 6940 6941 createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; 6942 updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; 6943 createComputedPropertyName(expression: Expression): ComputedPropertyName; 6944 updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; 6945 6946 // 6947 // Signature elements 6948 // 6949 6950 createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; 6951 updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; 6952 createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; 6953 updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; 6954 createDecorator(expression: Expression): Decorator; 6955 updateDecorator(node: Decorator, expression: Expression): Decorator; 6956 6957 // 6958 // Type Elements 6959 // 6960 6961 createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; 6962 updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; 6963 createPropertyDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; 6964 updatePropertyDeclaration(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; 6965 createMethodSignature(modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): MethodSignature; 6966 updateMethodSignature(node: MethodSignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): MethodSignature; 6967 createMethodDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; 6968 updateMethodDeclaration(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; 6969 createConstructorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; 6970 updateConstructorDeclaration(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; 6971 createGetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; 6972 updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; 6973 createSetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; 6974 updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; 6975 createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; 6976 updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): CallSignatureDeclaration; 6977 createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; 6978 updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode | undefined): ConstructSignatureDeclaration; 6979 createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; 6980 /* @internal */ createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): IndexSignatureDeclaration; // eslint-disable-line @typescript-eslint/unified-signatures 6981 updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; 6982 createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; 6983 updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; 6984 6985 // 6986 // Types 6987 // 6988 6989 createKeywordTypeNode<TKind extends KeywordTypeSyntaxKind>(kind: TKind): KeywordTypeNode<TKind>; 6990 createTypePredicateNode(assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; 6991 updateTypePredicateNode(node: TypePredicateNode, assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; 6992 createTypeReferenceNode(typeName: string | EntityName, typeArguments?: readonly TypeNode[]): TypeReferenceNode; 6993 updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray<TypeNode> | undefined): TypeReferenceNode; 6994 createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): FunctionTypeNode; 6995 updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): FunctionTypeNode; 6996 createConstructorTypeNode(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; 6997 /** @deprecated */ 6998 createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; 6999 updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode; 7000 /** @deprecated */ 7001 updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray<TypeParameterDeclaration> | undefined, parameters: NodeArray<ParameterDeclaration>, type: TypeNode): ConstructorTypeNode; 7002 createTypeQueryNode(exprName: EntityName): TypeQueryNode; 7003 updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; 7004 createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; 7005 updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray<TypeElement>): TypeLiteralNode; 7006 createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; 7007 updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; 7008 createTupleTypeNode(elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode; 7009 updateTupleTypeNode(node: TupleTypeNode, elements: readonly (TypeNode | NamedTupleMember)[]): TupleTypeNode; 7010 createNamedTupleMember(dotDotDotToken: DotDotDotToken | undefined, name: Identifier, questionToken: QuestionToken | undefined, type: TypeNode): NamedTupleMember; 7011 updateNamedTupleMember(node: NamedTupleMember, dotDotDotToken: DotDotDotToken | undefined, name: Identifier, questionToken: QuestionToken | undefined, type: TypeNode): NamedTupleMember; 7012 createOptionalTypeNode(type: TypeNode): OptionalTypeNode; 7013 updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; 7014 createRestTypeNode(type: TypeNode): RestTypeNode; 7015 updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; 7016 createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; 7017 updateUnionTypeNode(node: UnionTypeNode, types: NodeArray<TypeNode>): UnionTypeNode; 7018 createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; 7019 updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray<TypeNode>): IntersectionTypeNode; 7020 createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; 7021 updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; 7022 createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; 7023 updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; 7024 createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; 7025 updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; 7026 createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; 7027 updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; 7028 createThisTypeNode(): ThisTypeNode; 7029 createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; 7030 updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; 7031 createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; 7032 updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; 7033 createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; 7034 updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; 7035 createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; 7036 updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; 7037 createTemplateLiteralType(head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode; 7038 updateTemplateLiteralType(node: TemplateLiteralTypeNode, head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode; 7039 7040 // 7041 // Binding Patterns 7042 // 7043 7044 createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; 7045 updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; 7046 createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; 7047 updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; 7048 createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; 7049 updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; 7050 7051 // 7052 // Expression 7053 // 7054 7055 createArrayLiteralExpression(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; 7056 updateArrayLiteralExpression(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; 7057 createObjectLiteralExpression(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; 7058 updateObjectLiteralExpression(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; 7059 createPropertyAccessExpression(expression: Expression, name: string | Identifier | PrivateIdentifier): PropertyAccessExpression; 7060 updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier): PropertyAccessExpression; 7061 createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier): PropertyAccessChain; 7062 updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier): PropertyAccessChain; 7063 createElementAccessExpression(expression: Expression, index: number | Expression): ElementAccessExpression; 7064 updateElementAccessExpression(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; 7065 createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; 7066 updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain; 7067 createCallExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; 7068 updateCallExpression(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; 7069 createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain; 7070 updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain; 7071 createNewExpression(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; 7072 updateNewExpression(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; 7073 createTaggedTemplateExpression(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; 7074 updateTaggedTemplateExpression(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; 7075 createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; 7076 updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; 7077 createParenthesizedExpression(expression: Expression): ParenthesizedExpression; 7078 updateParenthesizedExpression(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; 7079 createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; 7080 updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; 7081 createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; 7082 updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; 7083 createEtsComponentExpression(name: Identifier, argumentExpression: readonly Expression[] | undefined, body: Block | undefined): EtsComponentExpression; 7084 updateEtsComponentExpression(node: EtsComponentExpression, name: Identifier | undefined, argumentExpression: readonly Expression[] | undefined, body: Block | undefined): EtsComponentExpression; 7085 createDeleteExpression(expression: Expression): DeleteExpression; 7086 updateDeleteExpression(node: DeleteExpression, expression: Expression): DeleteExpression; 7087 createTypeOfExpression(expression: Expression): TypeOfExpression; 7088 updateTypeOfExpression(node: TypeOfExpression, expression: Expression): TypeOfExpression; 7089 createVoidExpression(expression: Expression): VoidExpression; 7090 updateVoidExpression(node: VoidExpression, expression: Expression): VoidExpression; 7091 createAwaitExpression(expression: Expression): AwaitExpression; 7092 updateAwaitExpression(node: AwaitExpression, expression: Expression): AwaitExpression; 7093 createPrefixUnaryExpression(operator: PrefixUnaryOperator, operand: Expression): PrefixUnaryExpression; 7094 updatePrefixUnaryExpression(node: PrefixUnaryExpression, operand: Expression): PrefixUnaryExpression; 7095 createPostfixUnaryExpression(operand: Expression, operator: PostfixUnaryOperator): PostfixUnaryExpression; 7096 updatePostfixUnaryExpression(node: PostfixUnaryExpression, operand: Expression): PostfixUnaryExpression; 7097 createBinaryExpression(left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; 7098 updateBinaryExpression(node: BinaryExpression, left: Expression, operator: BinaryOperator | BinaryOperatorToken, right: Expression): BinaryExpression; 7099 createConditionalExpression(condition: Expression, questionToken: QuestionToken | undefined, whenTrue: Expression, colonToken: ColonToken | undefined, whenFalse: Expression): ConditionalExpression; 7100 updateConditionalExpression(node: ConditionalExpression, condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; 7101 createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; 7102 updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; 7103 createTemplateHead(text: string, rawText?: string, templateFlags?: TokenFlags): TemplateHead; 7104 createTemplateHead(text: string | undefined, rawText: string, templateFlags?: TokenFlags): TemplateHead; 7105 createTemplateMiddle(text: string, rawText?: string, templateFlags?: TokenFlags): TemplateMiddle; 7106 createTemplateMiddle(text: string | undefined, rawText: string, templateFlags?: TokenFlags): TemplateMiddle; 7107 createTemplateTail(text: string, rawText?: string, templateFlags?: TokenFlags): TemplateTail; 7108 createTemplateTail(text: string | undefined, rawText: string, templateFlags?: TokenFlags): TemplateTail; 7109 createNoSubstitutionTemplateLiteral(text: string, rawText?: string): NoSubstitutionTemplateLiteral; 7110 createNoSubstitutionTemplateLiteral(text: string | undefined, rawText: string): NoSubstitutionTemplateLiteral; 7111 /* @internal */ createLiteralLikeNode(kind: LiteralToken["kind"] | SyntaxKind.JsxTextAllWhiteSpaces, text: string): LiteralToken; 7112 /* @internal */ createTemplateLiteralLikeNode(kind: TemplateLiteralToken["kind"], text: string, rawText: string, templateFlags: TokenFlags | undefined): TemplateLiteralLikeNode; 7113 createYieldExpression(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; 7114 createYieldExpression(asteriskToken: undefined, expression: Expression | undefined): YieldExpression; 7115 /* @internal */ createYieldExpression(asteriskToken: AsteriskToken | undefined, expression: Expression | undefined): YieldExpression; // eslint-disable-line @typescript-eslint/unified-signatures 7116 updateYieldExpression(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression | undefined): YieldExpression; 7117 createSpreadElement(expression: Expression): SpreadElement; 7118 updateSpreadElement(node: SpreadElement, expression: Expression): SpreadElement; 7119 createClassExpression(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; 7120 updateClassExpression(node: ClassExpression, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; 7121 createOmittedExpression(): OmittedExpression; 7122 createExpressionWithTypeArguments(expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; 7123 updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; 7124 createAsExpression(expression: Expression, type: TypeNode): AsExpression; 7125 updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; 7126 createNonNullExpression(expression: Expression): NonNullExpression; 7127 updateNonNullExpression(node: NonNullExpression, expression: Expression): NonNullExpression; 7128 createNonNullChain(expression: Expression): NonNullChain; 7129 updateNonNullChain(node: NonNullChain, expression: Expression): NonNullChain; 7130 createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier): MetaProperty; 7131 updateMetaProperty(node: MetaProperty, name: Identifier): MetaProperty; 7132 7133 // 7134 // Misc 7135 // 7136 7137 createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; 7138 updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; 7139 createSemicolonClassElement(): SemicolonClassElement; 7140 7141 // 7142 // Element 7143 // 7144 7145 createBlock(statements: readonly Statement[], multiLine?: boolean): Block; 7146 updateBlock(node: Block, statements: readonly Statement[]): Block; 7147 createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; 7148 updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; 7149 createEmptyStatement(): EmptyStatement; 7150 createExpressionStatement(expression: Expression): ExpressionStatement; 7151 updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; 7152 createIfStatement(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; 7153 updateIfStatement(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; 7154 createDoStatement(statement: Statement, expression: Expression): DoStatement; 7155 updateDoStatement(node: DoStatement, statement: Statement, expression: Expression): DoStatement; 7156 createWhileStatement(expression: Expression, statement: Statement): WhileStatement; 7157 updateWhileStatement(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; 7158 createForStatement(initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; 7159 updateForStatement(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; 7160 createForInStatement(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; 7161 updateForInStatement(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; 7162 createForOfStatement(awaitModifier: AwaitKeyword | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; 7163 updateForOfStatement(node: ForOfStatement, awaitModifier: AwaitKeyword | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; 7164 createContinueStatement(label?: string | Identifier): ContinueStatement; 7165 updateContinueStatement(node: ContinueStatement, label: Identifier | undefined): ContinueStatement; 7166 createBreakStatement(label?: string | Identifier): BreakStatement; 7167 updateBreakStatement(node: BreakStatement, label: Identifier | undefined): BreakStatement; 7168 createReturnStatement(expression?: Expression): ReturnStatement; 7169 updateReturnStatement(node: ReturnStatement, expression: Expression | undefined): ReturnStatement; 7170 createWithStatement(expression: Expression, statement: Statement): WithStatement; 7171 updateWithStatement(node: WithStatement, expression: Expression, statement: Statement): WithStatement; 7172 createSwitchStatement(expression: Expression, caseBlock: CaseBlock): SwitchStatement; 7173 updateSwitchStatement(node: SwitchStatement, expression: Expression, caseBlock: CaseBlock): SwitchStatement; 7174 createLabeledStatement(label: string | Identifier, statement: Statement): LabeledStatement; 7175 updateLabeledStatement(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; 7176 createThrowStatement(expression: Expression): ThrowStatement; 7177 updateThrowStatement(node: ThrowStatement, expression: Expression): ThrowStatement; 7178 createTryStatement(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; 7179 updateTryStatement(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; 7180 createDebuggerStatement(): DebuggerStatement; 7181 createVariableDeclaration(name: string | BindingName, exclamationToken?: ExclamationToken, type?: TypeNode, initializer?: Expression): VariableDeclaration; 7182 updateVariableDeclaration(node: VariableDeclaration, name: BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; 7183 createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; 7184 updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; 7185 createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; 7186 updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; 7187 createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; 7188 updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; 7189 createStructDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): StructDeclaration; 7190 updateStructDeclaration(node: StructDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): StructDeclaration; 7191 createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; 7192 updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; 7193 createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; 7194 updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; 7195 createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; 7196 updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; 7197 createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; 7198 updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; 7199 createModuleBlock(statements: readonly Statement[]): ModuleBlock; 7200 updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; 7201 createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; 7202 updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; 7203 createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; 7204 updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; 7205 createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; 7206 updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; 7207 createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; 7208 updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; 7209 createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; 7210 updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; 7211 createNamespaceImport(name: Identifier): NamespaceImport; 7212 updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; 7213 createNamespaceExport(name: Identifier): NamespaceExport; 7214 updateNamespaceExport(node: NamespaceExport, name: Identifier): NamespaceExport; 7215 createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; 7216 updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; 7217 createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; 7218 updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; 7219 createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; 7220 updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; 7221 createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression): ExportDeclaration; 7222 updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; 7223 createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; 7224 updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; 7225 createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; 7226 updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; 7227 /* @internal*/ createMissingDeclaration(): MissingDeclaration; 7228 7229 // 7230 // Module references 7231 // 7232 7233 createExternalModuleReference(expression: Expression): ExternalModuleReference; 7234 updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; 7235 7236 // 7237 // JSDoc 7238 // 7239 7240 createJSDocAllType(): JSDocAllType; 7241 createJSDocUnknownType(): JSDocUnknownType; 7242 createJSDocNonNullableType(type: TypeNode): JSDocNonNullableType; 7243 updateJSDocNonNullableType(node: JSDocNonNullableType, type: TypeNode): JSDocNonNullableType; 7244 createJSDocNullableType(type: TypeNode): JSDocNullableType; 7245 updateJSDocNullableType(node: JSDocNullableType, type: TypeNode): JSDocNullableType; 7246 createJSDocOptionalType(type: TypeNode): JSDocOptionalType; 7247 updateJSDocOptionalType(node: JSDocOptionalType, type: TypeNode): JSDocOptionalType; 7248 createJSDocFunctionType(parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): JSDocFunctionType; 7249 updateJSDocFunctionType(node: JSDocFunctionType, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): JSDocFunctionType; 7250 createJSDocVariadicType(type: TypeNode): JSDocVariadicType; 7251 updateJSDocVariadicType(node: JSDocVariadicType, type: TypeNode): JSDocVariadicType; 7252 createJSDocNamepathType(type: TypeNode): JSDocNamepathType; 7253 updateJSDocNamepathType(node: JSDocNamepathType, type: TypeNode): JSDocNamepathType; 7254 createJSDocTypeExpression(type: TypeNode): JSDocTypeExpression; 7255 updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; 7256 createJSDocNameReference(name: EntityName): JSDocNameReference; 7257 updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; 7258 createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; 7259 updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; 7260 createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; 7261 updateJSDocSignature(node: JSDocSignature, typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type: JSDocReturnTag | undefined): JSDocSignature; 7262 createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string): JSDocTemplateTag; 7263 updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | undefined): JSDocTemplateTag; 7264 createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocTypedefTag; 7265 updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocTypedefTag; 7266 createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocParameterTag; 7267 updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocParameterTag; 7268 createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocPropertyTag; 7269 updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocPropertyTag; 7270 createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag; 7271 updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocTypeTag; 7272 createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; 7273 updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; 7274 createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string): JSDocReturnTag; 7275 updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocReturnTag; 7276 createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocThisTag; 7277 updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocThisTag; 7278 createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocEnumTag; 7279 updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocEnumTag; 7280 createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocCallbackTag; 7281 updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocCallbackTag; 7282 createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string): JSDocAugmentsTag; 7283 updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | undefined): JSDocAugmentsTag; 7284 createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string): JSDocImplementsTag; 7285 updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | undefined): JSDocImplementsTag; 7286 createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string): JSDocAuthorTag; 7287 updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | undefined): JSDocAuthorTag; 7288 createJSDocClassTag(tagName: Identifier | undefined, comment?: string): JSDocClassTag; 7289 updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | undefined): JSDocClassTag; 7290 createJSDocPublicTag(tagName: Identifier | undefined, comment?: string): JSDocPublicTag; 7291 updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPublicTag; 7292 createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string): JSDocPrivateTag; 7293 updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPrivateTag; 7294 createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string): JSDocProtectedTag; 7295 updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | undefined): JSDocProtectedTag; 7296 createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string): JSDocReadonlyTag; 7297 updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | undefined): JSDocReadonlyTag; 7298 createJSDocUnknownTag(tagName: Identifier, comment?: string): JSDocUnknownTag; 7299 updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | undefined): JSDocUnknownTag; 7300 createJSDocDeprecatedTag(tagName: Identifier, comment?: string): JSDocDeprecatedTag; 7301 updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string): JSDocDeprecatedTag; 7302 createJSDocComment(comment?: string | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; 7303 updateJSDocComment(node: JSDoc, comment: string | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; 7304 7305 // 7306 // JSX 7307 // 7308 7309 createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; 7310 updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; 7311 createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; 7312 updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; 7313 createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; 7314 updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; 7315 createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; 7316 updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; 7317 createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; 7318 createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; 7319 updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; 7320 createJsxOpeningFragment(): JsxOpeningFragment; 7321 createJsxJsxClosingFragment(): JsxClosingFragment; 7322 updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; 7323 createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; 7324 updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression | undefined): JsxAttribute; 7325 createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; 7326 updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; 7327 createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; 7328 updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; 7329 createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; 7330 updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; 7331 7332 // 7333 // Clauses 7334 // 7335 7336 createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; 7337 updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; 7338 createDefaultClause(statements: readonly Statement[]): DefaultClause; 7339 updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; 7340 createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; 7341 updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; 7342 createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; 7343 updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; 7344 7345 // 7346 // Property assignments 7347 // 7348 7349 createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; 7350 updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; 7351 createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment; 7352 updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression | undefined): ShorthandPropertyAssignment; 7353 createSpreadAssignment(expression: Expression): SpreadAssignment; 7354 updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; 7355 7356 // 7357 // Enum 7358 // 7359 7360 createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; 7361 updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; 7362 7363 // 7364 // Top-level nodes 7365 // 7366 7367 createSourceFile(statements: readonly Statement[], endOfFileToken: EndOfFileToken, flags: NodeFlags): SourceFile; 7368 updateSourceFile(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: readonly FileReference[], typeReferences?: readonly FileReference[], hasNoDefaultLib?: boolean, libReferences?: readonly FileReference[]): SourceFile; 7369 7370 /* @internal */ createUnparsedSource(prologues: readonly UnparsedPrologue[], syntheticReferences: readonly UnparsedSyntheticReference[] | undefined, texts: readonly UnparsedSourceText[]): UnparsedSource; 7371 /* @internal */ createUnparsedPrologue(data?: string): UnparsedPrologue; 7372 /* @internal */ createUnparsedPrepend(data: string | undefined, texts: readonly UnparsedSourceText[]): UnparsedPrepend; 7373 /* @internal */ createUnparsedTextLike(data: string | undefined, internal: boolean): UnparsedTextLike; 7374 /* @internal */ createUnparsedSyntheticReference(section: BundleFileHasNoDefaultLib | BundleFileReference): UnparsedSyntheticReference; 7375 /* @internal */ createInputFiles(): InputFiles; 7376 7377 // 7378 // Synthetic Nodes 7379 // 7380 /* @internal */ createSyntheticExpression(type: Type, isSpread?: boolean, tupleNameSource?: ParameterDeclaration | NamedTupleMember): SyntheticExpression; 7381 /* @internal */ createSyntaxList(children: Node[]): SyntaxList; 7382 7383 // 7384 // Transformation nodes 7385 // 7386 7387 createNotEmittedStatement(original: Node): NotEmittedStatement; 7388 /* @internal */ createEndOfDeclarationMarker(original: Node): EndOfDeclarationMarker; 7389 /* @internal */ createMergeDeclarationMarker(original: Node): MergeDeclarationMarker; 7390 createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; 7391 updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; 7392 /* @internal */ createSyntheticReferenceExpression(expression: Expression, thisArg: Expression): SyntheticReferenceExpression; 7393 /* @internal */ updateSyntheticReferenceExpression(node: SyntheticReferenceExpression, expression: Expression, thisArg: Expression): SyntheticReferenceExpression; 7394 createCommaListExpression(elements: readonly Expression[]): CommaListExpression; 7395 updateCommaListExpression(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; 7396 createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; 7397 updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; 7398 7399 // 7400 // Common operators 7401 // 7402 7403 createComma(left: Expression, right: Expression): BinaryExpression; 7404 createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; 7405 createAssignment(left: Expression, right: Expression): AssignmentExpression<EqualsToken>; 7406 createLogicalOr(left: Expression, right: Expression): BinaryExpression; 7407 createLogicalAnd(left: Expression, right: Expression): BinaryExpression; 7408 createBitwiseOr(left: Expression, right: Expression): BinaryExpression; 7409 createBitwiseXor(left: Expression, right: Expression): BinaryExpression; 7410 createBitwiseAnd(left: Expression, right: Expression): BinaryExpression; 7411 createStrictEquality(left: Expression, right: Expression): BinaryExpression; 7412 createStrictInequality(left: Expression, right: Expression): BinaryExpression; 7413 createEquality(left: Expression, right: Expression): BinaryExpression; 7414 createInequality(left: Expression, right: Expression): BinaryExpression; 7415 createLessThan(left: Expression, right: Expression): BinaryExpression; 7416 createLessThanEquals(left: Expression, right: Expression): BinaryExpression; 7417 createGreaterThan(left: Expression, right: Expression): BinaryExpression; 7418 createGreaterThanEquals(left: Expression, right: Expression): BinaryExpression; 7419 createLeftShift(left: Expression, right: Expression): BinaryExpression; 7420 createRightShift(left: Expression, right: Expression): BinaryExpression; 7421 createUnsignedRightShift(left: Expression, right: Expression): BinaryExpression; 7422 createAdd(left: Expression, right: Expression): BinaryExpression; 7423 createSubtract(left: Expression, right: Expression): BinaryExpression; 7424 createMultiply(left: Expression, right: Expression): BinaryExpression; 7425 createDivide(left: Expression, right: Expression): BinaryExpression; 7426 createModulo(left: Expression, right: Expression): BinaryExpression; 7427 createExponent(left: Expression, right: Expression): BinaryExpression; 7428 createPrefixPlus(operand: Expression): PrefixUnaryExpression; 7429 createPrefixMinus(operand: Expression): PrefixUnaryExpression; 7430 createPrefixIncrement(operand: Expression): PrefixUnaryExpression; 7431 createPrefixDecrement(operand: Expression): PrefixUnaryExpression; 7432 createBitwiseNot(operand: Expression): PrefixUnaryExpression; 7433 createLogicalNot(operand: Expression): PrefixUnaryExpression; 7434 createPostfixIncrement(operand: Expression): PostfixUnaryExpression; 7435 createPostfixDecrement(operand: Expression): PostfixUnaryExpression; 7436 7437 // 7438 // Compound Nodes 7439 // 7440 7441 createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; 7442 createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; 7443 createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; 7444 createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; 7445 7446 7447 createVoidZero(): VoidExpression; 7448 createExportDefault(expression: Expression): ExportAssignment; 7449 createExternalModuleExport(exportName: Identifier): ExportDeclaration; 7450 7451 /* @internal */ createTypeCheck(value: Expression, tag: TypeOfTag): Expression; 7452 /* @internal */ createMethodCall(object: Expression, methodName: string | Identifier, argumentsList: readonly Expression[]): CallExpression; 7453 /* @internal */ createGlobalMethodCall(globalObjectName: string, globalMethodName: string, argumentsList: readonly Expression[]): CallExpression; 7454 /* @internal */ createFunctionBindCall(target: Expression, thisArg: Expression, argumentsList: readonly Expression[]): CallExpression; 7455 /* @internal */ createFunctionCallCall(target: Expression, thisArg: Expression, argumentsList: readonly Expression[]): CallExpression; 7456 /* @internal */ createFunctionApplyCall(target: Expression, thisArg: Expression, argumentsExpression: Expression): CallExpression; 7457 /* @internal */ createObjectDefinePropertyCall(target: Expression, propertyName: string | Expression, attributes: Expression): CallExpression; 7458 /* @internal */ createPropertyDescriptor(attributes: PropertyDescriptorAttributes, singleLine?: boolean): ObjectLiteralExpression; 7459 /* @internal */ createArraySliceCall(array: Expression, start?: number | Expression): CallExpression; 7460 /* @internal */ createArrayConcatCall(array: Expression, values: readonly Expression[]): CallExpression; 7461 /* @internal */ createCallBinding(expression: Expression, recordTempVariable: (temp: Identifier) => void, languageVersion?: ScriptTarget, cacheIdentifiers?: boolean): CallBinding; 7462 /* @internal */ inlineExpressions(expressions: readonly Expression[]): Expression; 7463 /** 7464 * Gets the internal name of a declaration. This is primarily used for declarations that can be 7465 * referred to by name in the body of an ES5 class function body. An internal name will *never* 7466 * be prefixed with an module or namespace export modifier like "exports." when emitted as an 7467 * expression. An internal name will also *never* be renamed due to a collision with a block 7468 * scoped variable. 7469 * 7470 * @param node The declaration. 7471 * @param allowComments A value indicating whether comments may be emitted for the name. 7472 * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. 7473 */ 7474 /* @internal */ getInternalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; 7475 /** 7476 * Gets the local name of a declaration. This is primarily used for declarations that can be 7477 * referred to by name in the declaration's immediate scope (classes, enums, namespaces). A 7478 * local name will *never* be prefixed with an module or namespace export modifier like 7479 * "exports." when emitted as an expression. 7480 * 7481 * @param node The declaration. 7482 * @param allowComments A value indicating whether comments may be emitted for the name. 7483 * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. 7484 */ 7485 /* @internal */ getLocalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; 7486 /** 7487 * Gets the export name of a declaration. This is primarily used for declarations that can be 7488 * referred to by name in the declaration's immediate scope (classes, enums, namespaces). An 7489 * export name will *always* be prefixed with a module or namespace export modifier like 7490 * `"exports."` when emitted as an expression if the name points to an exported symbol. 7491 * 7492 * @param node The declaration. 7493 * @param allowComments A value indicating whether comments may be emitted for the name. 7494 * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. 7495 */ 7496 /* @internal */ getExportName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; 7497 /** 7498 * Gets the name of a declaration for use in declarations. 7499 * 7500 * @param node The declaration. 7501 * @param allowComments A value indicating whether comments may be emitted for the name. 7502 * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. 7503 */ 7504 /* @internal */ getDeclarationName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier; 7505 /** 7506 * Gets a namespace-qualified name for use in expressions. 7507 * 7508 * @param ns The namespace identifier. 7509 * @param name The name. 7510 * @param allowComments A value indicating whether comments may be emitted for the name. 7511 * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. 7512 */ 7513 /* @internal */ getNamespaceMemberName(ns: Identifier, name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): PropertyAccessExpression; 7514 /** 7515 * Gets the exported name of a declaration for use in expressions. 7516 * 7517 * An exported name will *always* be prefixed with an module or namespace export modifier like 7518 * "exports." if the name points to an exported symbol. 7519 * 7520 * @param ns The namespace identifier. 7521 * @param node The declaration. 7522 * @param allowComments A value indicating whether comments may be emitted for the name. 7523 * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. 7524 */ 7525 /* @internal */ getExternalModuleOrNamespaceExportName(ns: Identifier | undefined, node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean): Identifier | PropertyAccessExpression; 7526 7527 // 7528 // Utilities 7529 // 7530 7531 restoreOuterExpressions(outerExpression: Expression | undefined, innerExpression: Expression, kinds?: OuterExpressionKinds): Expression; 7532 /* @internal */ restoreEnclosingLabel(node: Statement, outermostLabeledStatement: LabeledStatement | undefined, afterRestoreLabelCallback?: (node: LabeledStatement) => void): Statement; 7533 /* @internal */ createUseStrictPrologue(): PrologueDirective; 7534 /** 7535 * Copies any necessary standard and custom prologue-directives into target array. 7536 * @param source origin statements array 7537 * @param target result statements array 7538 * @param ensureUseStrict boolean determining whether the function need to add prologue-directives 7539 * @param visitor Optional callback used to visit any custom prologue directives. 7540 */ 7541 /* @internal */ copyPrologue(source: readonly Statement[], target: Push<Statement>, ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult<Node>): number; 7542 /** 7543 * Copies only the standard (string-expression) prologue-directives into the target statement-array. 7544 * @param source origin statements array 7545 * @param target result statements array 7546 * @param ensureUseStrict boolean determining whether the function need to add prologue-directives 7547 */ 7548 /* @internal */ copyStandardPrologue(source: readonly Statement[], target: Push<Statement>, ensureUseStrict?: boolean): number; 7549 /** 7550 * Copies only the custom prologue-directives into target statement-array. 7551 * @param source origin statements array 7552 * @param target result statements array 7553 * @param statementOffset The offset at which to begin the copy. 7554 * @param visitor Optional callback used to visit any custom prologue directives. 7555 */ 7556 /* @internal */ copyCustomPrologue(source: readonly Statement[], target: Push<Statement>, statementOffset: number, visitor?: (node: Node) => VisitResult<Node>, filter?: (node: Node) => boolean): number; 7557 /* @internal */ copyCustomPrologue(source: readonly Statement[], target: Push<Statement>, statementOffset: number | undefined, visitor?: (node: Node) => VisitResult<Node>, filter?: (node: Node) => boolean): number | undefined; 7558 /* @internal */ ensureUseStrict(statements: NodeArray<Statement>): NodeArray<Statement>; 7559 /* @internal */ liftToBlock(nodes: readonly Node[]): Statement; 7560 /** 7561 * Merges generated lexical declarations into a new statement list. 7562 */ 7563 /* @internal */ mergeLexicalEnvironment(statements: NodeArray<Statement>, declarations: readonly Statement[] | undefined): NodeArray<Statement>; 7564 /** 7565 * Appends generated lexical declarations to an array of statements. 7566 */ 7567 /* @internal */ mergeLexicalEnvironment(statements: Statement[], declarations: readonly Statement[] | undefined): Statement[]; 7568 /** 7569 * Creates a shallow, memberwise clone of a node. 7570 * - The result will have its `original` pointer set to `node`. 7571 * - The result will have its `pos` and `end` set to `-1`. 7572 * - *DO NOT USE THIS* if a more appropriate function is available. 7573 */ 7574 /* @internal */ cloneNode<T extends Node | undefined>(node: T): T; 7575 /* @internal */ updateModifiers<T extends HasModifiers>(node: T, modifiers: readonly Modifier[] | ModifierFlags): T; 7576 } 7577 7578 /* @internal */ 7579 export const enum LexicalEnvironmentFlags { 7580 None = 0, 7581 InParameters = 1 << 0, // currently visiting a parameter list 7582 VariablesHoistedInParameters = 1 << 1 // a temp variable was hoisted while visiting a parameter list 7583 } 7584 7585 export interface CoreTransformationContext { 7586 readonly factory: NodeFactory; 7587 7588 /** Gets the compiler options supplied to the transformer. */ 7589 getCompilerOptions(): CompilerOptions; 7590 7591 /** Starts a new lexical environment. */ 7592 startLexicalEnvironment(): void; 7593 7594 /* @internal */ setLexicalEnvironmentFlags(flags: LexicalEnvironmentFlags, value: boolean): void; 7595 /* @internal */ getLexicalEnvironmentFlags(): LexicalEnvironmentFlags; 7596 7597 /** Suspends the current lexical environment, usually after visiting a parameter list. */ 7598 suspendLexicalEnvironment(): void; 7599 7600 /** Resumes a suspended lexical environment, usually before visiting a function body. */ 7601 resumeLexicalEnvironment(): void; 7602 7603 /** Ends a lexical environment, returning any declarations. */ 7604 endLexicalEnvironment(): Statement[] | undefined; 7605 7606 /** Hoists a function declaration to the containing scope. */ 7607 hoistFunctionDeclaration(node: FunctionDeclaration): void; 7608 7609 /** Hoists a variable declaration to the containing scope. */ 7610 hoistVariableDeclaration(node: Identifier): void; 7611 7612 /** Adds an initialization statement to the top of the lexical environment. */ 7613 /* @internal */ 7614 addInitializationStatement(node: Statement): void; 7615 } 7616 7617 export interface TransformationContext extends CoreTransformationContext { 7618 /*@internal*/ getEmitResolver(): EmitResolver; 7619 /*@internal*/ getEmitHost(): EmitHost; 7620 /*@internal*/ getEmitHelperFactory(): EmitHelperFactory; 7621 7622 /** Records a request for a non-scoped emit helper in the current context. */ 7623 requestEmitHelper(helper: EmitHelper): void; 7624 7625 /** Gets and resets the requested non-scoped emit helpers. */ 7626 readEmitHelpers(): EmitHelper[] | undefined; 7627 7628 /** Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ 7629 enableSubstitution(kind: SyntaxKind): void; 7630 7631 /** Determines whether expression substitutions are enabled for the provided node. */ 7632 isSubstitutionEnabled(node: Node): boolean; 7633 7634 /** 7635 * Hook used by transformers to substitute expressions just before they 7636 * are emitted by the pretty printer. 7637 * 7638 * NOTE: Transformation hooks should only be modified during `Transformer` initialization, 7639 * before returning the `NodeTransformer` callback. 7640 */ 7641 onSubstituteNode: (hint: EmitHint, node: Node) => Node; 7642 7643 /** 7644 * Enables before/after emit notifications in the pretty printer for the provided 7645 * SyntaxKind. 7646 */ 7647 enableEmitNotification(kind: SyntaxKind): void; 7648 7649 /** 7650 * Determines whether before/after emit notifications should be raised in the pretty 7651 * printer when it emits a node. 7652 */ 7653 isEmitNotificationEnabled(node: Node): boolean; 7654 7655 /** 7656 * Hook used to allow transformers to capture state before or after 7657 * the printer emits a node. 7658 * 7659 * NOTE: Transformation hooks should only be modified during `Transformer` initialization, 7660 * before returning the `NodeTransformer` callback. 7661 */ 7662 onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; 7663 7664 /* @internal */ addDiagnostic(diag: DiagnosticWithLocation): void; 7665 } 7666 7667 export interface TransformationResult<T extends Node> { 7668 /** Gets the transformed source files. */ 7669 transformed: T[]; 7670 7671 /** Gets diagnostics for the transformation. */ 7672 diagnostics?: DiagnosticWithLocation[]; 7673 7674 /** 7675 * Gets a substitute for a node, if one is available; otherwise, returns the original node. 7676 * 7677 * @param hint A hint as to the intended usage of the node. 7678 * @param node The node to substitute. 7679 */ 7680 substituteNode(hint: EmitHint, node: Node): Node; 7681 7682 /** 7683 * Emits a node with possible notification. 7684 * 7685 * @param hint A hint as to the intended usage of the node. 7686 * @param node The node to emit. 7687 * @param emitCallback A callback used to emit the node. 7688 */ 7689 emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; 7690 7691 /** 7692 * Indicates if a given node needs an emit notification 7693 * 7694 * @param node The node to emit. 7695 */ 7696 isEmitNotificationEnabled?(node: Node): boolean; 7697 7698 /** 7699 * Clean up EmitNode entries on any parse-tree nodes. 7700 */ 7701 dispose(): void; 7702 } 7703 7704 /** 7705 * A function that is used to initialize and return a `Transformer` callback, which in turn 7706 * will be used to transform one or more nodes. 7707 */ 7708 export type TransformerFactory<T extends Node> = (context: TransformationContext) => Transformer<T>; 7709 7710 /** 7711 * A function that transforms a node. 7712 */ 7713 export type Transformer<T extends Node> = (node: T) => T; 7714 7715 /** 7716 * A function that accepts and possibly transforms a node. 7717 */ 7718 export type Visitor = (node: Node) => VisitResult<Node>; 7719 7720 export interface NodeVisitor { 7721 <T extends Node>(nodes: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T; 7722 <T extends Node>(nodes: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined; 7723 } 7724 7725 export interface NodesVisitor { 7726 <T extends Node>(nodes: NodeArray<T>, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T>; 7727 <T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T> | undefined; 7728 } 7729 7730 export type VisitResult<T extends Node> = T | T[] | undefined; 7731 7732 export interface Printer { 7733 /** 7734 * Print a node and its subtree as-is, without any emit transformations. 7735 * @param hint A value indicating the purpose of a node. This is primarily used to 7736 * distinguish between an `Identifier` used in an expression position, versus an 7737 * `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you 7738 * should just pass `Unspecified`. 7739 * @param node The node to print. The node and its subtree are printed as-is, without any 7740 * emit transformations. 7741 * @param sourceFile A source file that provides context for the node. The source text of 7742 * the file is used to emit the original source content for literals and identifiers, while 7743 * the identifiers of the source file are used when generating unique names to avoid 7744 * collisions. 7745 */ 7746 printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; 7747 /** 7748 * Prints a list of nodes using the given format flags 7749 */ 7750 printList<T extends Node>(format: ListFormat, list: NodeArray<T>, sourceFile: SourceFile): string; 7751 /** 7752 * Prints a source file as-is, without any emit transformations. 7753 */ 7754 printFile(sourceFile: SourceFile): string; 7755 /** 7756 * Prints a bundle of source files as-is, without any emit transformations. 7757 */ 7758 printBundle(bundle: Bundle): string; 7759 /*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void; 7760 /*@internal*/ writeList<T extends Node>(format: ListFormat, list: NodeArray<T> | undefined, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void; 7761 writeFile(sourceFile: SourceFile, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void; 7762 /*@internal*/ writeBundle(bundle: Bundle, writer: EmitTextWriter, sourceMapGenerator: SourceMapGenerator | undefined): void; 7763 /*@internal*/ bundleFileInfo?: BundleFileInfo; 7764 } 7765 7766 /*@internal*/ 7767 export const enum BundleFileSectionKind { 7768 Prologue = "prologue", 7769 EmitHelpers = "emitHelpers", 7770 NoDefaultLib = "no-default-lib", 7771 Reference = "reference", 7772 Type = "type", 7773 Lib = "lib", 7774 Prepend = "prepend", 7775 Text = "text", 7776 Internal = "internal", 7777 // comments? 7778 } 7779 7780 /*@internal*/ 7781 export interface BundleFileSectionBase extends TextRange { 7782 kind: BundleFileSectionKind; 7783 data?: string; 7784 } 7785 7786 /*@internal*/ 7787 export interface BundleFilePrologue extends BundleFileSectionBase { 7788 kind: BundleFileSectionKind.Prologue; 7789 data: string; 7790 } 7791 7792 /*@internal*/ 7793 export interface BundleFileEmitHelpers extends BundleFileSectionBase { 7794 kind: BundleFileSectionKind.EmitHelpers; 7795 data: string; 7796 } 7797 7798 /*@internal*/ 7799 export interface BundleFileHasNoDefaultLib extends BundleFileSectionBase { 7800 kind: BundleFileSectionKind.NoDefaultLib; 7801 } 7802 7803 /*@internal*/ 7804 export interface BundleFileReference extends BundleFileSectionBase { 7805 kind: BundleFileSectionKind.Reference | BundleFileSectionKind.Type | BundleFileSectionKind.Lib; 7806 data: string; 7807 } 7808 7809 /*@internal*/ 7810 export interface BundleFilePrepend extends BundleFileSectionBase { 7811 kind: BundleFileSectionKind.Prepend; 7812 data: string; 7813 texts: BundleFileTextLike[]; 7814 } 7815 7816 /*@internal*/ 7817 export type BundleFileTextLikeKind = BundleFileSectionKind.Text | BundleFileSectionKind.Internal; 7818 7819 /*@internal*/ 7820 export interface BundleFileTextLike extends BundleFileSectionBase { 7821 kind: BundleFileTextLikeKind; 7822 } 7823 7824 /*@internal*/ 7825 export type BundleFileSection = 7826 BundleFilePrologue 7827 | BundleFileEmitHelpers 7828 | BundleFileHasNoDefaultLib 7829 | BundleFileReference 7830 | BundleFilePrepend 7831 | BundleFileTextLike; 7832 7833 /*@internal*/ 7834 export interface SourceFilePrologueDirectiveExpression extends TextRange { 7835 text: string; 7836 } 7837 7838 /*@internal*/ 7839 export interface SourceFilePrologueDirective extends TextRange { 7840 expression: SourceFilePrologueDirectiveExpression; 7841 } 7842 7843 /*@internal*/ 7844 export interface SourceFilePrologueInfo { 7845 file: number; 7846 text: string; 7847 directives: SourceFilePrologueDirective[]; 7848 } 7849 7850 /*@internal*/ 7851 export interface SourceFileInfo { 7852 // List of helpers in own source files emitted if no prepend is present 7853 helpers?: string[]; 7854 prologues?: SourceFilePrologueInfo[]; 7855 } 7856 7857 /*@internal*/ 7858 export interface BundleFileInfo { 7859 sections: BundleFileSection[]; 7860 sources?: SourceFileInfo; 7861 } 7862 7863 /*@internal*/ 7864 export interface BundleBuildInfo { 7865 js?: BundleFileInfo; 7866 dts?: BundleFileInfo; 7867 commonSourceDirectory: string; 7868 sourceFiles: readonly string[]; 7869 } 7870 7871 /* @internal */ 7872 export interface BuildInfo { 7873 bundle?: BundleBuildInfo; 7874 program?: ProgramBuildInfo; 7875 version: string; 7876 } 7877 7878 export interface PrintHandlers { 7879 /** 7880 * A hook used by the Printer when generating unique names to avoid collisions with 7881 * globally defined names that exist outside of the current source file. 7882 */ 7883 hasGlobalName?(name: string): boolean; 7884 /** 7885 * A hook used by the Printer to provide notifications prior to emitting a node. A 7886 * compatible implementation **must** invoke `emitCallback` with the provided `hint` and 7887 * `node` values. 7888 * @param hint A hint indicating the intended purpose of the node. 7889 * @param node The node to emit. 7890 * @param emitCallback A callback that, when invoked, will emit the node. 7891 * @example 7892 * ```ts 7893 * var printer = createPrinter(printerOptions, { 7894 * onEmitNode(hint, node, emitCallback) { 7895 * // set up or track state prior to emitting the node... 7896 * emitCallback(hint, node); 7897 * // restore state after emitting the node... 7898 * } 7899 * }); 7900 * ``` 7901 */ 7902 onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; 7903 7904 /** 7905 * A hook used to check if an emit notification is required for a node. 7906 * @param node The node to emit. 7907 */ 7908 isEmitNotificationEnabled?(node: Node | undefined): boolean; 7909 /** 7910 * A hook used by the Printer to perform just-in-time substitution of a node. This is 7911 * primarily used by node transformations that need to substitute one node for another, 7912 * such as replacing `myExportedVar` with `exports.myExportedVar`. 7913 * @param hint A hint indicating the intended purpose of the node. 7914 * @param node The node to emit. 7915 * @example 7916 * ```ts 7917 * var printer = createPrinter(printerOptions, { 7918 * substituteNode(hint, node) { 7919 * // perform substitution if necessary... 7920 * return node; 7921 * } 7922 * }); 7923 * ``` 7924 */ 7925 substituteNode?(hint: EmitHint, node: Node): Node; 7926 /*@internal*/ onEmitSourceMapOfNode?: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; 7927 /*@internal*/ onEmitSourceMapOfToken?: (node: Node | undefined, token: SyntaxKind, writer: (s: string) => void, pos: number, emitCallback: (token: SyntaxKind, writer: (s: string) => void, pos: number) => number) => number; 7928 /*@internal*/ onEmitSourceMapOfPosition?: (pos: number) => void; 7929 /*@internal*/ onSetSourceFile?: (node: SourceFile) => void; 7930 /*@internal*/ onBeforeEmitNodeArray?: (nodes: NodeArray<any> | undefined) => void; 7931 /*@internal*/ onAfterEmitNodeArray?: (nodes: NodeArray<any> | undefined) => void; 7932 /*@internal*/ onBeforeEmitToken?: (node: Node) => void; 7933 /*@internal*/ onAfterEmitToken?: (node: Node) => void; 7934 } 7935 7936 export interface PrinterOptions { 7937 removeComments?: boolean; 7938 newLine?: NewLineKind; 7939 omitTrailingSemicolon?: boolean; 7940 noEmitHelpers?: boolean; 7941 /*@internal*/ module?: CompilerOptions["module"]; 7942 /*@internal*/ target?: CompilerOptions["target"]; 7943 sourceMap?: boolean; 7944 inlineSourceMap?: boolean; 7945 inlineSources?: boolean; 7946 /*@internal*/ extendedDiagnostics?: boolean; 7947 /*@internal*/ onlyPrintJsDocStyle?: boolean; 7948 /*@internal*/ neverAsciiEscape?: boolean; 7949 /*@internal*/ writeBundleFileInfo?: boolean; 7950 /*@internal*/ recordInternalSection?: boolean; 7951 /*@internal*/ stripInternal?: boolean; 7952 /*@internal*/ preserveSourceNewlines?: boolean; 7953 /*@internal*/ terminateUnterminatedLiterals?: boolean; 7954 /*@internal*/ relativeToBuildInfo?: (path: string) => string; 7955 } 7956 7957 export interface RawSourceMap { 7958 version: 3; 7959 file: string; 7960 sourceRoot?: string | null; 7961 sources: string[]; 7962 sourcesContent?: (string | null)[] | null; 7963 mappings: string; 7964 names?: string[] | null; 7965 } 7966 7967 /** 7968 * Generates a source map. 7969 */ 7970 export interface SourceMapGenerator { 7971 getSources(): readonly string[]; 7972 /** 7973 * Adds a source to the source map. 7974 */ 7975 addSource(fileName: string): number; 7976 /** 7977 * Set the content for a source. 7978 */ 7979 setSourceContent(sourceIndex: number, content: string | null): void; 7980 /** 7981 * Adds a name. 7982 */ 7983 addName(name: string): number; 7984 /** 7985 * Adds a mapping without source information. 7986 */ 7987 addMapping(generatedLine: number, generatedCharacter: number): void; 7988 /** 7989 * Adds a mapping with source information. 7990 */ 7991 addMapping(generatedLine: number, generatedCharacter: number, sourceIndex: number, sourceLine: number, sourceCharacter: number, nameIndex?: number): void; 7992 /** 7993 * Appends a source map. 7994 */ 7995 appendSourceMap(generatedLine: number, generatedCharacter: number, sourceMap: RawSourceMap, sourceMapPath: string, start?: LineAndCharacter, end?: LineAndCharacter): void; 7996 /** 7997 * Gets the source map as a `RawSourceMap` object. 7998 */ 7999 toJSON(): RawSourceMap; 8000 /** 8001 * Gets the string representation of the source map. 8002 */ 8003 toString(): string; 8004 } 8005 8006 /* @internal */ 8007 export interface DocumentPositionMapperHost { 8008 getSourceFileLike(fileName: string): SourceFileLike | undefined; 8009 getCanonicalFileName(path: string): string; 8010 log(text: string): void; 8011 } 8012 8013 /** 8014 * Maps positions between source and generated files. 8015 */ 8016 /* @internal */ 8017 export interface DocumentPositionMapper { 8018 getSourcePosition(input: DocumentPosition): DocumentPosition; 8019 getGeneratedPosition(input: DocumentPosition): DocumentPosition; 8020 } 8021 8022 /* @internal */ 8023 export interface DocumentPosition { 8024 fileName: string; 8025 pos: number; 8026 } 8027 8028 export interface EmitTextWriter extends SymbolWriter { 8029 write(s: string): void; 8030 writeTrailingSemicolon(text: string): void; 8031 writeComment(text: string): void; 8032 getText(): string; 8033 rawWrite(s: string): void; 8034 writeLiteral(s: string): void; 8035 getTextPos(): number; 8036 getLine(): number; 8037 getColumn(): number; 8038 getIndent(): number; 8039 isAtStartOfLine(): boolean; 8040 hasTrailingComment(): boolean; 8041 hasTrailingWhitespace(): boolean; 8042 getTextPosWithWriteLine?(): number; 8043 } 8044 8045 export interface GetEffectiveTypeRootsHost { 8046 directoryExists?(directoryName: string): boolean; 8047 getCurrentDirectory?(): string; 8048 } 8049 8050 export interface ModuleSpecifierResolutionHost { 8051 useCaseSensitiveFileNames?(): boolean; 8052 fileExists(path: string): boolean; 8053 getCurrentDirectory(): string; 8054 directoryExists?(path: string): boolean; 8055 readFile?(path: string): string | undefined; 8056 realpath?(path: string): string; 8057 /* @internal */ 8058 getSymlinkCache?(): SymlinkCache; 8059 getGlobalTypingsCacheLocation?(): string | undefined; 8060 getNearestAncestorDirectoryWithPackageJson?(fileName: string, rootDir?: string): string | undefined; 8061 8062 getSourceFiles(): readonly SourceFile[]; 8063 readonly redirectTargetsMap: RedirectTargetsMap; 8064 getProjectReferenceRedirect(fileName: string): string | undefined; 8065 isSourceOfProjectReferenceRedirect(fileName: string): boolean; 8066 /* @internal */ 8067 getFileIncludeReasons(): MultiMap<Path, FileIncludeReason>; 8068 } 8069 8070 // Note: this used to be deprecated in our public API, but is still used internally 8071 export interface SymbolTracker { 8072 // Called when the symbol writer encounters a symbol to write. Currently only used by the 8073 // declaration emitter to help determine if it should patch up the final declaration file 8074 // with import statements it previously saw (but chose not to emit). 8075 trackSymbol?(symbol: Symbol, enclosingDeclaration: Node | undefined, meaning: SymbolFlags): void; 8076 reportInaccessibleThisError?(): void; 8077 reportPrivateInBaseOfClassExpression?(propertyName: string): void; 8078 reportInaccessibleUniqueSymbolError?(): void; 8079 reportCyclicStructureError?(): void; 8080 reportLikelyUnsafeImportRequiredError?(specifier: string): void; 8081 reportTruncationError?(): void; 8082 moduleResolverHost?: ModuleSpecifierResolutionHost & { getCommonSourceDirectory(): string }; 8083 trackReferencedAmbientModule?(decl: ModuleDeclaration, symbol: Symbol): void; 8084 trackExternalModuleSymbolOfImportTypeNode?(symbol: Symbol): void; 8085 reportNonlocalAugmentation?(containingFile: SourceFile, parentSymbol: Symbol, augmentingSymbol: Symbol): void; 8086 } 8087 8088 export interface TextSpan { 8089 start: number; 8090 length: number; 8091 } 8092 8093 export interface TextChangeRange { 8094 span: TextSpan; 8095 newLength: number; 8096 } 8097 8098 /* @internal */ 8099 export interface DiagnosticCollection { 8100 // Adds a diagnostic to this diagnostic collection. 8101 add(diagnostic: Diagnostic): void; 8102 8103 // Returns the first existing diagnostic that is equivalent to the given one (sans related information) 8104 lookup(diagnostic: Diagnostic): Diagnostic | undefined; 8105 8106 // Gets all the diagnostics that aren't associated with a file. 8107 getGlobalDiagnostics(): Diagnostic[]; 8108 8109 // If fileName is provided, gets all the diagnostics associated with that file name. 8110 // Otherwise, returns all the diagnostics (global and file associated) in this collection. 8111 getDiagnostics(): Diagnostic[]; 8112 getDiagnostics(fileName: string): DiagnosticWithLocation[]; 8113 } 8114 8115 // SyntaxKind.SyntaxList 8116 export interface SyntaxList extends Node { 8117 kind: SyntaxKind.SyntaxList; 8118 _children: Node[]; 8119 } 8120 8121 export const enum ListFormat { 8122 None = 0, 8123 8124 // Line separators 8125 SingleLine = 0, // Prints the list on a single line (default). 8126 MultiLine = 1 << 0, // Prints the list on multiple lines. 8127 PreserveLines = 1 << 1, // Prints the list using line preservation if possible. 8128 LinesMask = SingleLine | MultiLine | PreserveLines, 8129 8130 // Delimiters 8131 NotDelimited = 0, // There is no delimiter between list items (default). 8132 BarDelimited = 1 << 2, // Each list item is space-and-bar (" |") delimited. 8133 AmpersandDelimited = 1 << 3, // Each list item is space-and-ampersand (" &") delimited. 8134 CommaDelimited = 1 << 4, // Each list item is comma (",") delimited. 8135 AsteriskDelimited = 1 << 5, // Each list item is asterisk ("\n *") delimited, used with JSDoc. 8136 DelimitersMask = BarDelimited | AmpersandDelimited | CommaDelimited | AsteriskDelimited, 8137 8138 AllowTrailingComma = 1 << 6, // Write a trailing comma (",") if present. 8139 8140 // Whitespace 8141 Indented = 1 << 7, // The list should be indented. 8142 SpaceBetweenBraces = 1 << 8, // Inserts a space after the opening brace and before the closing brace. 8143 SpaceBetweenSiblings = 1 << 9, // Inserts a space between each sibling node. 8144 8145 // Brackets/Braces 8146 Braces = 1 << 10, // The list is surrounded by "{" and "}". 8147 Parenthesis = 1 << 11, // The list is surrounded by "(" and ")". 8148 AngleBrackets = 1 << 12, // The list is surrounded by "<" and ">". 8149 SquareBrackets = 1 << 13, // The list is surrounded by "[" and "]". 8150 BracketsMask = Braces | Parenthesis | AngleBrackets | SquareBrackets, 8151 8152 OptionalIfUndefined = 1 << 14, // Do not emit brackets if the list is undefined. 8153 OptionalIfEmpty = 1 << 15, // Do not emit brackets if the list is empty. 8154 Optional = OptionalIfUndefined | OptionalIfEmpty, 8155 8156 // Other 8157 PreferNewLine = 1 << 16, // Prefer adding a LineTerminator between synthesized nodes. 8158 NoTrailingNewLine = 1 << 17, // Do not emit a trailing NewLine for a MultiLine list. 8159 NoInterveningComments = 1 << 18, // Do not emit comments between each node 8160 8161 NoSpaceIfEmpty = 1 << 19, // If the literal is empty, do not add spaces between braces. 8162 SingleElement = 1 << 20, 8163 SpaceAfterList = 1 << 21, // Add space after list 8164 8165 // Precomputed Formats 8166 Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments, 8167 HeritageClauses = SingleLine | SpaceBetweenSiblings, 8168 SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings, 8169 MultiLineTypeLiteralMembers = MultiLine | Indented | OptionalIfEmpty, 8170 8171 SingleLineTupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine, 8172 MultiLineTupleTypeElements = CommaDelimited | Indented | SpaceBetweenSiblings | MultiLine, 8173 UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine, 8174 IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine, 8175 ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings | NoSpaceIfEmpty, 8176 ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings | NoSpaceIfEmpty, 8177 ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces | NoSpaceIfEmpty, 8178 ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets, 8179 CommaListElements = CommaDelimited | SpaceBetweenSiblings | SingleLine, 8180 CallExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis, 8181 NewExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis | OptionalIfUndefined, 8182 TemplateExpressionSpans = SingleLine | NoInterveningComments, 8183 SingleLineBlockStatements = SpaceBetweenBraces | SpaceBetweenSiblings | SingleLine, 8184 MultiLineBlockStatements = Indented | MultiLine, 8185 VariableDeclarationList = CommaDelimited | SpaceBetweenSiblings | SingleLine, 8186 SingleLineFunctionBodyStatements = SingleLine | SpaceBetweenSiblings | SpaceBetweenBraces, 8187 MultiLineFunctionBodyStatements = MultiLine, 8188 ClassHeritageClauses = SingleLine, 8189 ClassMembers = Indented | MultiLine, 8190 InterfaceMembers = Indented | MultiLine, 8191 EnumMembers = CommaDelimited | Indented | MultiLine, 8192 CaseBlockClauses = Indented | MultiLine, 8193 NamedImportsOrExportsElements = CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | SingleLine | SpaceBetweenBraces | NoSpaceIfEmpty, 8194 JsxElementOrFragmentChildren = SingleLine | NoInterveningComments, 8195 JsxElementAttributes = SingleLine | SpaceBetweenSiblings | NoInterveningComments, 8196 CaseOrDefaultClauseStatements = Indented | MultiLine | NoTrailingNewLine | OptionalIfEmpty, 8197 HeritageClauseTypes = CommaDelimited | SpaceBetweenSiblings | SingleLine, 8198 SourceFileStatements = MultiLine | NoTrailingNewLine, 8199 Decorators = MultiLine | Optional | SpaceAfterList, 8200 TypeArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | AngleBrackets | Optional, 8201 TypeParameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | AngleBrackets | Optional, 8202 Parameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis, 8203 IndexSignatureParameters = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented | SquareBrackets, 8204 JSDocComment = MultiLine | AsteriskDelimited, 8205 } 8206 8207 /* @internal */ 8208 export const enum PragmaKindFlags { 8209 None = 0, 8210 /** 8211 * Triple slash comment of the form 8212 * /// <pragma-name argname="value" /> 8213 */ 8214 TripleSlashXML = 1 << 0, 8215 /** 8216 * Single line comment of the form 8217 * // @pragma-name argval1 argval2 8218 * or 8219 * /// @pragma-name argval1 argval2 8220 */ 8221 SingleLine = 1 << 1, 8222 /** 8223 * Multiline non-jsdoc pragma of the form 8224 * /* @pragma-name argval1 argval2 * / 8225 */ 8226 MultiLine = 1 << 2, 8227 All = TripleSlashXML | SingleLine | MultiLine, 8228 Default = All, 8229 } 8230 8231 /* @internal */ 8232 interface PragmaArgumentSpecification<TName extends string> { 8233 name: TName; // Determines the name of the key in the resulting parsed type, type parameter to cause literal type inference 8234 optional?: boolean; 8235 captureSpan?: boolean; 8236 } 8237 8238 /* @internal */ 8239 export interface PragmaDefinition<T1 extends string = string, T2 extends string = string, T3 extends string = string, T4 extends string = string> { 8240 args?: 8241 | readonly [PragmaArgumentSpecification<T1>] 8242 | readonly [PragmaArgumentSpecification<T1>, PragmaArgumentSpecification<T2>] 8243 | readonly [PragmaArgumentSpecification<T1>, PragmaArgumentSpecification<T2>, PragmaArgumentSpecification<T3>] 8244 | readonly [PragmaArgumentSpecification<T1>, PragmaArgumentSpecification<T2>, PragmaArgumentSpecification<T3>, PragmaArgumentSpecification<T4>]; 8245 // If not present, defaults to PragmaKindFlags.Default 8246 kind?: PragmaKindFlags; 8247 } 8248 8249 // While not strictly a type, this is here because `PragmaMap` needs to be here to be used with `SourceFile`, and we don't 8250 // fancy effectively defining it twice, once in value-space and once in type-space 8251 /* @internal */ 8252 export const commentPragmas = { 8253 "reference": { 8254 args: [ 8255 { name: "types", optional: true, captureSpan: true }, 8256 { name: "lib", optional: true, captureSpan: true }, 8257 { name: "path", optional: true, captureSpan: true }, 8258 { name: "no-default-lib", optional: true } 8259 ], 8260 kind: PragmaKindFlags.TripleSlashXML 8261 }, 8262 "amd-dependency": { 8263 args: [{ name: "path" }, { name: "name", optional: true }], 8264 kind: PragmaKindFlags.TripleSlashXML 8265 }, 8266 "amd-module": { 8267 args: [{ name: "name" }], 8268 kind: PragmaKindFlags.TripleSlashXML 8269 }, 8270 "ts-check": { 8271 kind: PragmaKindFlags.SingleLine 8272 }, 8273 "ts-nocheck": { 8274 kind: PragmaKindFlags.SingleLine 8275 }, 8276 "jsx": { 8277 args: [{ name: "factory" }], 8278 kind: PragmaKindFlags.MultiLine 8279 }, 8280 "jsxfrag": { 8281 args: [{ name: "factory" }], 8282 kind: PragmaKindFlags.MultiLine 8283 }, 8284 "jsximportsource": { 8285 args: [{ name: "factory" }], 8286 kind: PragmaKindFlags.MultiLine 8287 }, 8288 "jsxruntime": { 8289 args: [{ name: "factory" }], 8290 kind: PragmaKindFlags.MultiLine 8291 }, 8292 } as const; 8293 8294 /* @internal */ 8295 type PragmaArgTypeMaybeCapture<TDesc> = TDesc extends {captureSpan: true} ? {value: string, pos: number, end: number} : string; 8296 8297 /* @internal */ 8298 type PragmaArgTypeOptional<TDesc, TName extends string> = 8299 TDesc extends {optional: true} 8300 ? {[K in TName]?: PragmaArgTypeMaybeCapture<TDesc>} 8301 : {[K in TName]: PragmaArgTypeMaybeCapture<TDesc>}; 8302 8303 /* @internal */ 8304 type UnionToIntersection<U> = 8305 (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; 8306 8307 /* @internal */ 8308 type ArgumentDefinitionToFieldUnion<T extends readonly PragmaArgumentSpecification<any>[]> = { 8309 [K in keyof T]: PragmaArgTypeOptional<T[K], T[K] extends {name: infer TName} ? TName extends string ? TName : never : never> 8310 }[Extract<keyof T, number>]; // The mapped type maps over only the tuple members, but this reindex gets _all_ members - by extracting only `number` keys, we get only the tuple members 8311 8312 /** 8313 * Maps a pragma definition into the desired shape for its arguments object 8314 */ 8315 /* @internal */ 8316 type PragmaArgumentType<KPrag extends keyof ConcretePragmaSpecs> = 8317 ConcretePragmaSpecs[KPrag] extends { args: readonly PragmaArgumentSpecification<any>[] } 8318 ? UnionToIntersection<ArgumentDefinitionToFieldUnion<ConcretePragmaSpecs[KPrag]["args"]>> 8319 : never; 8320 8321 /* @internal */ 8322 type ConcretePragmaSpecs = typeof commentPragmas; 8323 8324 /* @internal */ 8325 export type PragmaPseudoMap = {[K in keyof ConcretePragmaSpecs]: {arguments: PragmaArgumentType<K>, range: CommentRange}}; 8326 8327 /* @internal */ 8328 export type PragmaPseudoMapEntry = {[K in keyof PragmaPseudoMap]: {name: K, args: PragmaPseudoMap[K]}}[keyof PragmaPseudoMap]; 8329 8330 /* @internal */ 8331 export interface ReadonlyPragmaMap extends ReadonlyESMap<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]> { 8332 get<TKey extends keyof PragmaPseudoMap>(key: TKey): PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][]; 8333 forEach(action: <TKey extends keyof PragmaPseudoMap>(value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][], key: TKey) => void): void; 8334 } 8335 8336 /** 8337 * A strongly-typed es6 map of pragma entries, the values of which are either a single argument 8338 * value (if only one was found), or an array of multiple argument values if the pragma is present 8339 * in multiple places 8340 */ 8341 /* @internal */ 8342 export interface PragmaMap extends ESMap<string, PragmaPseudoMap[keyof PragmaPseudoMap] | PragmaPseudoMap[keyof PragmaPseudoMap][]>, ReadonlyPragmaMap { 8343 set<TKey extends keyof PragmaPseudoMap>(key: TKey, value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][]): this; 8344 get<TKey extends keyof PragmaPseudoMap>(key: TKey): PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][]; 8345 forEach(action: <TKey extends keyof PragmaPseudoMap>(value: PragmaPseudoMap[TKey] | PragmaPseudoMap[TKey][], key: TKey) => void): void; 8346 } 8347 8348 /* @internal */ 8349 export interface CommentDirectivesMap { 8350 getUnusedExpectations(): CommentDirective[]; 8351 markUsed(matchedLine: number): boolean; 8352 } 8353 8354 export interface UserPreferences { 8355 readonly disableSuggestions?: boolean; 8356 readonly quotePreference?: "auto" | "double" | "single"; 8357 readonly includeCompletionsForModuleExports?: boolean; 8358 readonly includeAutomaticOptionalChainCompletions?: boolean; 8359 readonly includeCompletionsWithInsertText?: boolean; 8360 readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; 8361 /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ 8362 readonly importModuleSpecifierEnding?: "auto" | "minimal" | "index" | "js"; 8363 readonly allowTextChangesInNewFiles?: boolean; 8364 readonly providePrefixAndSuffixTextForRename?: boolean; 8365 readonly includePackageJsonAutoImports?: "auto" | "on" | "off"; 8366 readonly provideRefactorNotApplicableReason?: boolean; 8367 } 8368 8369 /** Represents a bigint literal value without requiring bigint support */ 8370 export interface PseudoBigInt { 8371 negative: boolean; 8372 base10Value: string; 8373 } 8374 8375 export interface JSDocTagInfo { 8376 name: string; 8377 text?: string; 8378 } 8379} 8380