UNPKG

typescript

Version:

TypeScript is a language for application scale JavaScript development

1,120 lines (1,117 loc) 321 kB
/*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ declare namespace ts { const versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ const version: string; /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, * since `Object.prototype` may be modified by outside code. */ interface MapLike<T> { [index: string]: T; } interface SortedReadonlyArray<T> extends ReadonlyArray<T> { " __sortedArrayBrand": any; } interface SortedArray<T> extends Array<T> { " __sortedArrayBrand": any; } /** ES6 Map interface, only read methods included. */ interface ReadonlyMap<T> { get(key: string): T | undefined; has(key: string): boolean; forEach(action: (value: T, key: string) => void): void; readonly size: number; keys(): Iterator<string>; values(): Iterator<T>; entries(): Iterator<[string, T]>; } /** ES6 Map interface. */ interface Map<T> extends ReadonlyMap<T> { set(key: string, value: T): this; delete(key: string): boolean; clear(): void; } /** ES6 Iterator type. */ interface Iterator<T> { next(): { value: T; done?: false; } | { value: never; done: true; }; } /** Array that is only intended to be pushed to, never read. */ interface Push<T> { push(...values: T[]): void; } } declare namespace ts { export type Path = string & { __pathBrand: any; }; export interface TextRange { pos: number; end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InferKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.OfKeyword; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, ShebangTrivia = 6, ConflictMarkerTrivia = 7, NumericLiteral = 8, BigIntLiteral = 9, StringLiteral = 10, JsxText = 11, JsxTextAllWhiteSpaces = 12, RegularExpressionLiteral = 13, NoSubstitutionTemplateLiteral = 14, TemplateHead = 15, TemplateMiddle = 16, TemplateTail = 17, OpenBraceToken = 18, CloseBraceToken = 19, OpenParenToken = 20, CloseParenToken = 21, OpenBracketToken = 22, CloseBracketToken = 23, DotToken = 24, DotDotDotToken = 25, SemicolonToken = 26, CommaToken = 27, QuestionDotToken = 28, LessThanToken = 29, LessThanSlashToken = 30, GreaterThanToken = 31, LessThanEqualsToken = 32, GreaterThanEqualsToken = 33, EqualsEqualsToken = 34, ExclamationEqualsToken = 35, EqualsEqualsEqualsToken = 36, ExclamationEqualsEqualsToken = 37, EqualsGreaterThanToken = 38, PlusToken = 39, MinusToken = 40, AsteriskToken = 41, AsteriskAsteriskToken = 42, SlashToken = 43, PercentToken = 44, PlusPlusToken = 45, MinusMinusToken = 46, LessThanLessThanToken = 47, GreaterThanGreaterThanToken = 48, GreaterThanGreaterThanGreaterThanToken = 49, AmpersandToken = 50, BarToken = 51, CaretToken = 52, ExclamationToken = 53, TildeToken = 54, AmpersandAmpersandToken = 55, BarBarToken = 56, QuestionToken = 57, ColonToken = 58, AtToken = 59, QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ BacktickToken = 61, EqualsToken = 62, PlusEqualsToken = 63, MinusEqualsToken = 64, AsteriskEqualsToken = 65, AsteriskAsteriskEqualsToken = 66, SlashEqualsToken = 67, PercentEqualsToken = 68, LessThanLessThanEqualsToken = 69, GreaterThanGreaterThanEqualsToken = 70, GreaterThanGreaterThanGreaterThanEqualsToken = 71, AmpersandEqualsToken = 72, BarEqualsToken = 73, CaretEqualsToken = 74, Identifier = 75, PrivateIdentifier = 76, BreakKeyword = 77, CaseKeyword = 78, CatchKeyword = 79, ClassKeyword = 80, ConstKeyword = 81, ContinueKeyword = 82, DebuggerKeyword = 83, DefaultKeyword = 84, DeleteKeyword = 85, DoKeyword = 86, ElseKeyword = 87, EnumKeyword = 88, ExportKeyword = 89, ExtendsKeyword = 90, FalseKeyword = 91, FinallyKeyword = 92, ForKeyword = 93, FunctionKeyword = 94, IfKeyword = 95, ImportKeyword = 96, InKeyword = 97, InstanceOfKeyword = 98, NewKeyword = 99, NullKeyword = 100, ReturnKeyword = 101, SuperKeyword = 102, SwitchKeyword = 103, ThisKeyword = 104, ThrowKeyword = 105, TrueKeyword = 106, TryKeyword = 107, TypeOfKeyword = 108, VarKeyword = 109, VoidKeyword = 110, WhileKeyword = 111, WithKeyword = 112, ImplementsKeyword = 113, InterfaceKeyword = 114, LetKeyword = 115, PackageKeyword = 116, PrivateKeyword = 117, ProtectedKeyword = 118, PublicKeyword = 119, StaticKeyword = 120, YieldKeyword = 121, AbstractKeyword = 122, AsKeyword = 123, AssertsKeyword = 124, AnyKeyword = 125, AsyncKeyword = 126, AwaitKeyword = 127, BooleanKeyword = 128, ConstructorKeyword = 129, DeclareKeyword = 130, GetKeyword = 131, InferKeyword = 132, IsKeyword = 133, KeyOfKeyword = 134, ModuleKeyword = 135, NamespaceKeyword = 136, NeverKeyword = 137, ReadonlyKeyword = 138, RequireKeyword = 139, NumberKeyword = 140, ObjectKeyword = 141, SetKeyword = 142, StringKeyword = 143, SymbolKeyword = 144, TypeKeyword = 145, UndefinedKeyword = 146, UniqueKeyword = 147, UnknownKeyword = 148, FromKeyword = 149, GlobalKeyword = 150, BigIntKeyword = 151, OfKeyword = 152, QualifiedName = 153, ComputedPropertyName = 154, TypeParameter = 155, Parameter = 156, Decorator = 157, PropertySignature = 158, PropertyDeclaration = 159, MethodSignature = 160, MethodDeclaration = 161, Constructor = 162, GetAccessor = 163, SetAccessor = 164, CallSignature = 165, ConstructSignature = 166, IndexSignature = 167, TypePredicate = 168, TypeReference = 169, FunctionType = 170, ConstructorType = 171, TypeQuery = 172, TypeLiteral = 173, ArrayType = 174, TupleType = 175, OptionalType = 176, RestType = 177, UnionType = 178, IntersectionType = 179, ConditionalType = 180, InferType = 181, ParenthesizedType = 182, ThisType = 183, TypeOperator = 184, IndexedAccessType = 185, MappedType = 186, LiteralType = 187, ImportType = 188, ObjectBindingPattern = 189, ArrayBindingPattern = 190, BindingElement = 191, ArrayLiteralExpression = 192, ObjectLiteralExpression = 193, PropertyAccessExpression = 194, ElementAccessExpression = 195, CallExpression = 196, NewExpression = 197, TaggedTemplateExpression = 198, TypeAssertionExpression = 199, ParenthesizedExpression = 200, FunctionExpression = 201, ArrowFunction = 202, DeleteExpression = 203, TypeOfExpression = 204, VoidExpression = 205, AwaitExpression = 206, PrefixUnaryExpression = 207, PostfixUnaryExpression = 208, BinaryExpression = 209, ConditionalExpression = 210, TemplateExpression = 211, YieldExpression = 212, SpreadElement = 213, ClassExpression = 214, OmittedExpression = 215, ExpressionWithTypeArguments = 216, AsExpression = 217, NonNullExpression = 218, MetaProperty = 219, SyntheticExpression = 220, TemplateSpan = 221, SemicolonClassElement = 222, Block = 223, EmptyStatement = 224, VariableStatement = 225, ExpressionStatement = 226, IfStatement = 227, DoStatement = 228, WhileStatement = 229, ForStatement = 230, ForInStatement = 231, ForOfStatement = 232, ContinueStatement = 233, BreakStatement = 234, ReturnStatement = 235, WithStatement = 236, SwitchStatement = 237, LabeledStatement = 238, ThrowStatement = 239, TryStatement = 240, DebuggerStatement = 241, VariableDeclaration = 242, VariableDeclarationList = 243, FunctionDeclaration = 244, ClassDeclaration = 245, InterfaceDeclaration = 246, TypeAliasDeclaration = 247, EnumDeclaration = 248, ModuleDeclaration = 249, ModuleBlock = 250, CaseBlock = 251, NamespaceExportDeclaration = 252, ImportEqualsDeclaration = 253, ImportDeclaration = 254, ImportClause = 255, NamespaceImport = 256, NamedImports = 257, ImportSpecifier = 258, ExportAssignment = 259, ExportDeclaration = 260, NamedExports = 261, NamespaceExport = 262, ExportSpecifier = 263, MissingDeclaration = 264, ExternalModuleReference = 265, JsxElement = 266, JsxSelfClosingElement = 267, JsxOpeningElement = 268, JsxClosingElement = 269, JsxFragment = 270, JsxOpeningFragment = 271, JsxClosingFragment = 272, JsxAttribute = 273, JsxAttributes = 274, JsxSpreadAttribute = 275, JsxExpression = 276, CaseClause = 277, DefaultClause = 278, HeritageClause = 279, CatchClause = 280, PropertyAssignment = 281, ShorthandPropertyAssignment = 282, SpreadAssignment = 283, EnumMember = 284, UnparsedPrologue = 285, UnparsedPrepend = 286, UnparsedText = 287, UnparsedInternalText = 288, UnparsedSyntheticReference = 289, SourceFile = 290, Bundle = 291, UnparsedSource = 292, InputFiles = 293, JSDocTypeExpression = 294, JSDocAllType = 295, JSDocUnknownType = 296, JSDocNullableType = 297, JSDocNonNullableType = 298, JSDocOptionalType = 299, JSDocFunctionType = 300, JSDocVariadicType = 301, JSDocNamepathType = 302, JSDocComment = 303, JSDocTypeLiteral = 304, JSDocSignature = 305, JSDocTag = 306, JSDocAugmentsTag = 307, JSDocImplementsTag = 308, JSDocAuthorTag = 309, JSDocClassTag = 310, JSDocPublicTag = 311, JSDocPrivateTag = 312, JSDocProtectedTag = 313, JSDocReadonlyTag = 314, JSDocCallbackTag = 315, JSDocEnumTag = 316, JSDocParameterTag = 317, JSDocReturnTag = 318, JSDocThisTag = 319, JSDocTypeTag = 320, JSDocTemplateTag = 321, JSDocTypedefTag = 322, JSDocPropertyTag = 323, SyntaxList = 324, NotEmittedStatement = 325, PartiallyEmittedExpression = 326, CommaListExpression = 327, MergeDeclarationMarker = 328, EndOfDeclarationMarker = 329, SyntheticReferenceExpression = 330, Count = 331, FirstAssignment = 62, LastAssignment = 74, FirstCompoundAssignment = 63, LastCompoundAssignment = 74, FirstReservedWord = 77, LastReservedWord = 112, FirstKeyword = 77, LastKeyword = 152, FirstFutureReservedWord = 113, LastFutureReservedWord = 121, FirstTypeNode = 168, LastTypeNode = 188, FirstPunctuation = 18, LastPunctuation = 74, FirstToken = 0, LastToken = 152, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 14, FirstTemplateToken = 14, LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 74, FirstStatement = 225, LastStatement = 241, FirstNode = 153, FirstJSDocNode = 294, LastJSDocNode = 323, FirstJSDocTagNode = 306, LastJSDocTagNode = 323, } export enum NodeFlags { None = 0, Let = 1, Const = 2, NestedNamespace = 4, Synthesized = 8, Namespace = 16, OptionalChain = 32, ExportContext = 64, ContainsThis = 128, HasImplicitReturn = 256, HasExplicitReturn = 512, GlobalAugmentation = 1024, HasAsyncFunctions = 2048, DisallowInContext = 4096, YieldContext = 8192, DecoratorContext = 16384, AwaitContext = 32768, ThisNodeHasError = 65536, JavaScriptFile = 131072, ThisNodeOrAnySubNodesHasError = 262144, HasAggregatedChildData = 524288, JSDoc = 4194304, JsonFile = 33554432, BlockScoped = 3, ReachabilityCheckFlags = 768, ReachabilityAndEmitFlags = 2816, ContextFlags = 25358336, TypeExcludesFlags = 40960, } export enum ModifierFlags { None = 0, Export = 1, Ambient = 2, Public = 4, Private = 8, Protected = 16, Static = 32, Readonly = 64, Abstract = 128, Async = 256, Default = 512, Const = 2048, HasComputedFlags = 536870912, AccessibilityModifier = 28, ParameterPropertyModifier = 92, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 2270, ExportDefault = 513, All = 3071 } export enum JsxFlags { None = 0, /** An element from a named property of the JSX.IntrinsicElements interface */ IntrinsicNamedElement = 1, /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ IntrinsicIndexedElement = 2, IntrinsicElement = 3 } export interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray<Decorator>; modifiers?: ModifiersArray; parent: Node; } export interface JSDocContainer { } export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | EndOfFileToken; export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; export interface NodeArray<T extends Node> extends ReadonlyArray<T>, TextRange { hasTrailingComma?: boolean; } export interface Token<TKind extends SyntaxKind> extends Node { kind: TKind; } export type DotToken = Token<SyntaxKind.DotToken>; export type DotDotDotToken = Token<SyntaxKind.DotDotDotToken>; export type QuestionToken = Token<SyntaxKind.QuestionToken>; export type QuestionDotToken = Token<SyntaxKind.QuestionDotToken>; export type ExclamationToken = Token<SyntaxKind.ExclamationToken>; export type ColonToken = Token<SyntaxKind.ColonToken>; export type EqualsToken = Token<SyntaxKind.EqualsToken>; export type AsteriskToken = Token<SyntaxKind.AsteriskToken>; export type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>; export type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer; export type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>; export type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>; export type PlusToken = Token<SyntaxKind.PlusToken>; export type MinusToken = Token<SyntaxKind.MinusToken>; export type AssertsToken = Token<SyntaxKind.AssertsKeyword>; export type Modifier = Token<SyntaxKind.AbstractKeyword> | Token<SyntaxKind.AsyncKeyword> | Token<SyntaxKind.ConstKeyword> | Token<SyntaxKind.DeclareKeyword> | Token<SyntaxKind.DefaultKeyword> | Token<SyntaxKind.ExportKeyword> | Token<SyntaxKind.PublicKeyword> | Token<SyntaxKind.PrivateKeyword> | Token<SyntaxKind.ProtectedKeyword> | Token<SyntaxKind.ReadonlyKeyword> | Token<SyntaxKind.StaticKeyword>; export type ModifiersArray = NodeArray<Modifier>; export interface Identifier extends PrimaryExpression, Declaration { kind: SyntaxKind.Identifier; /** * Prefer to use `id.unescapedText`. (Note: This is available only in services, not internally to the TypeScript compiler.) * Text of identifier, but if the identifier begins with two underscores, this will begin with three. */ escapedText: __String; originalKeywordKind?: SyntaxKind; isInJSDocNamespace?: boolean; } export interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } export interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; export type DeclarationName = Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; } export interface NamedDeclaration extends Declaration { name?: DeclarationName; } export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } export interface ComputedPropertyName extends Node { parent: Declaration; kind: SyntaxKind.ComputedPropertyName; expression: Expression; } export interface PrivateIdentifier extends Node { kind: SyntaxKind.PrivateIdentifier; escapedText: __String; } export interface Decorator extends Node { kind: SyntaxKind.Decorator; parent: NamedDeclaration; expression: LeftHandSideExpression; } export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent: DeclarationWithTypeParameterChildren | InferTypeNode; name: Identifier; /** Note: Consider calling `getEffectiveConstraintOfTypeParameter` */ constraint?: TypeNode; default?: TypeNode; expression?: Expression; } export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray<TypeParameterDeclaration>; parameters: NodeArray<ParameterDeclaration>; type?: TypeNode; } export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } export interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } export type BindingName = Identifier | BindingPattern; export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent: VariableDeclarationList | CatchClause; name: BindingName; exclamationToken?: ExclamationToken; type?: TypeNode; initializer?: Expression; } export interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray<VariableDeclaration>; } export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; initializer?: Expression; } export interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } export interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; parent: ClassLikeDeclaration; name: PropertyName; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; type?: TypeNode; initializer?: Expression; } export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrand: any; name?: PropertyName; } /** Unlike ObjectLiteralElement, excludes JSXAttribute and JSXSpreadAttribute. */ export type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; export interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; equalsToken?: Token<SyntaxKind.EqualsToken>; objectAssignmentInitializer?: Expression; } export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } export type VariableLikeDeclaration = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | PropertySignature | JsxAttribute | ShorthandPropertyAssignment | EnumMember | JSDocPropertyTag | JSDocParameterTag; export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } export interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray<BindingElement>; } export interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray<ArrayBindingElement>; } export type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; export type ArrayBindingElement = BindingElement | OmittedExpression; /** * Several node kinds share function-like features such as a signature, * a name, and a body. These nodes should extend FunctionLikeDeclarationBase. * Examples: * - FunctionDeclaration * - MethodDeclaration * - AccessorDeclaration */ export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; body?: Block | Expression; } export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ export type FunctionLike = SignatureDeclaration; export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } export interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; parent: ObjectTypeDeclaration; name: PropertyName; } export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent: ClassLikeDeclaration; } export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent: ObjectTypeDeclaration; } export interface TypeNode extends Node { _typeNodeBrand: any; } export interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } export interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; isTypeOf?: boolean; argument: TypeNode; qualifier?: EntityName; } export interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; export interface FunctionOrConstructorTypeNodeBase extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; type: TypeNode; } export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.FunctionType; } export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { kind: SyntaxKind.ConstructorType; } export interface NodeWithTypeArguments extends TypeNode { typeArguments?: NodeArray<TypeNode>; } export type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; export interface TypeReferenceNode extends NodeWithTypeArguments { kind: SyntaxKind.TypeReference; typeName: EntityName; } export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; type?: TypeNode; } export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray<TypeElement>; } export interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } export interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray<TypeNode>; } export interface OptionalTypeNode extends TypeNode { kind: SyntaxKind.OptionalType; type: TypeNode; } export interface RestTypeNode extends TypeNode { kind: SyntaxKind.RestType; type: TypeNode; } export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; export interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray<TypeNode>; } export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray<TypeNode>; } export interface ConditionalTypeNode extends TypeNode { kind: SyntaxKind.ConditionalType; checkType: TypeNode; extendsType: TypeNode; trueType: TypeNode; falseType: TypeNode; } export interface InferTypeNode extends TypeNode { kind: SyntaxKind.InferType; typeParameter: TypeParameterDeclaration; } export interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } export interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword; type: TypeNode; } export interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken | PlusToken | MinusToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken | PlusToken | MinusToken; type?: TypeNode; } export interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } export interface StringLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.StringLiteral; } export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; export interface Expression extends Node { _expressionBrand: any; } export interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } export interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } export interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ export type IncrementExpression = UpdateExpression; export interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } export type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; export interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } export type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; export interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } export interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } export interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } export interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } export interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } export interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } export interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } export interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } export interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } export interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } export interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } export interface SyntheticExpression extends Expression { kind: SyntaxKind.SyntheticExpression; isSpread: boolean; type: Type; } export type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; export type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; export type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; export type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; export type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; export type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; export type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; export type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; export type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; export type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; export type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; export type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; export type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; export type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; export type BinaryOperatorToken = Token<BinaryOperator>; export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } export type AssignmentOperatorToken = Token<AssignmentOperator>; export interface AssignmentExpression<TOperator extends AssignmentOperatorToken> extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } export interface ObjectDestructuringAssignment extends AssignmentExpression<EqualsToken> { left: ObjectLiteralExpression; } export interface ArrayDestructuringAssignment extends AssignmentExpression<EqualsToken> { left: ArrayLiteralExpression; } export type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; export type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression<EqualsToken> | Identifier | PropertyAccessExpression | ElementAccessExpression; export type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; export type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Identifier | PropertyAccessExpression | ElementAccessExpression | OmittedExpression; export type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; export type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; export type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; export type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; export interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; whenTrue: Expression; colonToken: ColonToken; whenFalse: Expression; } export type FunctionBody = Block; export type ConciseBody = FunctionBody | Expression; export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; name: never; } export interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } export interface TemplateLiteralLikeNode extends LiteralLikeNode { rawText?: string; } export interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } export enum TokenFlags { None = 0, Scientific = 16, Octal = 32, HexSpecifier = 64, BinarySpecifier = 128, OctalSpecifier = 256, } export interface NumericLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.NumericLiteral; } export interface BigIntLiteral extends LiteralExpression { kind: SyntaxKind.BigIntLiteral; } export interface TemplateHead extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateHead; parent: TemplateExpression; } export interface TemplateMiddle extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent: TemplateSpan; } export interface TemplateTail extends TemplateLiteralLikeNode { kind: SyntaxKind.TemplateTail; parent: TemplateSpan; } export type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; export interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray<TemplateSpan>; } export interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } export interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } export interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray<Expression>; } export interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } /** * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) */ export interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> extends PrimaryExpression, Declaration { properties: NodeArray<T>; } export interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike> { kind: SyntaxKind.ObjectLiteralExpression; } export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; questionDotToken?: QuestionDotToken; name: Identifier | PrivateIdentifier; } export interface PropertyAccessChain extends PropertyAccessExpression { _optionalChainBrand: any; name: Identifier; } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; name: Identifier; } export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; questionDotToken?: QuestionDotTok