UNPKG

pxt-core

Version:

Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors

1,248 lines (1,244 loc) • 231 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 { /** * 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; } /** 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; } type Path = string & { __pathBrand: any; }; interface TextRange { pos: number; end: number; } enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, MultiLineCommentTrivia = 3, NewLineTrivia = 4, WhitespaceTrivia = 5, ShebangTrivia = 6, ConflictMarkerTrivia = 7, NumericLiteral = 8, StringLiteral = 9, JsxText = 10, JsxTextAllWhiteSpaces = 11, RegularExpressionLiteral = 12, NoSubstitutionTemplateLiteral = 13, TemplateHead = 14, TemplateMiddle = 15, TemplateTail = 16, OpenBraceToken = 17, CloseBraceToken = 18, OpenParenToken = 19, CloseParenToken = 20, OpenBracketToken = 21, CloseBracketToken = 22, DotToken = 23, DotDotDotToken = 24, SemicolonToken = 25, CommaToken = 26, LessThanToken = 27, LessThanSlashToken = 28, GreaterThanToken = 29, LessThanEqualsToken = 30, GreaterThanEqualsToken = 31, EqualsEqualsToken = 32, ExclamationEqualsToken = 33, EqualsEqualsEqualsToken = 34, ExclamationEqualsEqualsToken = 35, EqualsGreaterThanToken = 36, PlusToken = 37, MinusToken = 38, AsteriskToken = 39, AsteriskAsteriskToken = 40, SlashToken = 41, PercentToken = 42, PlusPlusToken = 43, MinusMinusToken = 44, LessThanLessThanToken = 45, GreaterThanGreaterThanToken = 46, GreaterThanGreaterThanGreaterThanToken = 47, AmpersandToken = 48, BarToken = 49, CaretToken = 50, ExclamationToken = 51, TildeToken = 52, AmpersandAmpersandToken = 53, BarBarToken = 54, QuestionToken = 55, ColonToken = 56, AtToken = 57, EqualsToken = 58, PlusEqualsToken = 59, MinusEqualsToken = 60, AsteriskEqualsToken = 61, AsteriskAsteriskEqualsToken = 62, SlashEqualsToken = 63, PercentEqualsToken = 64, LessThanLessThanEqualsToken = 65, GreaterThanGreaterThanEqualsToken = 66, GreaterThanGreaterThanGreaterThanEqualsToken = 67, AmpersandEqualsToken = 68, BarEqualsToken = 69, CaretEqualsToken = 70, Identifier = 71, BreakKeyword = 72, CaseKeyword = 73, CatchKeyword = 74, ClassKeyword = 75, ConstKeyword = 76, ContinueKeyword = 77, DebuggerKeyword = 78, DefaultKeyword = 79, DeleteKeyword = 80, DoKeyword = 81, ElseKeyword = 82, EnumKeyword = 83, ExportKeyword = 84, ExtendsKeyword = 85, FalseKeyword = 86, FinallyKeyword = 87, ForKeyword = 88, FunctionKeyword = 89, IfKeyword = 90, ImportKeyword = 91, InKeyword = 92, InstanceOfKeyword = 93, NewKeyword = 94, NullKeyword = 95, ReturnKeyword = 96, SuperKeyword = 97, SwitchKeyword = 98, ThisKeyword = 99, ThrowKeyword = 100, TrueKeyword = 101, TryKeyword = 102, TypeOfKeyword = 103, VarKeyword = 104, VoidKeyword = 105, WhileKeyword = 106, WithKeyword = 107, ImplementsKeyword = 108, InterfaceKeyword = 109, LetKeyword = 110, PackageKeyword = 111, PrivateKeyword = 112, ProtectedKeyword = 113, PublicKeyword = 114, StaticKeyword = 115, YieldKeyword = 116, AbstractKeyword = 117, AsKeyword = 118, AnyKeyword = 119, AsyncKeyword = 120, AwaitKeyword = 121, BooleanKeyword = 122, ConstructorKeyword = 123, DeclareKeyword = 124, GetKeyword = 125, IsKeyword = 126, KeyOfKeyword = 127, ModuleKeyword = 128, NamespaceKeyword = 129, NeverKeyword = 130, ReadonlyKeyword = 131, RequireKeyword = 132, NumberKeyword = 133, ObjectKeyword = 134, SetKeyword = 135, StringKeyword = 136, SymbolKeyword = 137, TypeKeyword = 138, UndefinedKeyword = 139, FromKeyword = 140, GlobalKeyword = 141, OfKeyword = 142, QualifiedName = 143, ComputedPropertyName = 144, TypeParameter = 145, Parameter = 146, Decorator = 147, PropertySignature = 148, PropertyDeclaration = 149, MethodSignature = 150, MethodDeclaration = 151, Constructor = 152, GetAccessor = 153, SetAccessor = 154, CallSignature = 155, ConstructSignature = 156, IndexSignature = 157, TypePredicate = 158, TypeReference = 159, FunctionType = 160, ConstructorType = 161, TypeQuery = 162, TypeLiteral = 163, ArrayType = 164, TupleType = 165, UnionType = 166, IntersectionType = 167, ParenthesizedType = 168, ThisType = 169, TypeOperator = 170, IndexedAccessType = 171, MappedType = 172, LiteralType = 173, ObjectBindingPattern = 174, ArrayBindingPattern = 175, BindingElement = 176, ArrayLiteralExpression = 177, ObjectLiteralExpression = 178, PropertyAccessExpression = 179, ElementAccessExpression = 180, CallExpression = 181, NewExpression = 182, TaggedTemplateExpression = 183, TypeAssertionExpression = 184, ParenthesizedExpression = 185, FunctionExpression = 186, ArrowFunction = 187, DeleteExpression = 188, TypeOfExpression = 189, VoidExpression = 190, AwaitExpression = 191, PrefixUnaryExpression = 192, PostfixUnaryExpression = 193, BinaryExpression = 194, ConditionalExpression = 195, TemplateExpression = 196, YieldExpression = 197, SpreadElement = 198, ClassExpression = 199, OmittedExpression = 200, ExpressionWithTypeArguments = 201, AsExpression = 202, NonNullExpression = 203, MetaProperty = 204, TemplateSpan = 205, SemicolonClassElement = 206, Block = 207, VariableStatement = 208, EmptyStatement = 209, ExpressionStatement = 210, IfStatement = 211, DoStatement = 212, WhileStatement = 213, ForStatement = 214, ForInStatement = 215, ForOfStatement = 216, ContinueStatement = 217, BreakStatement = 218, ReturnStatement = 219, WithStatement = 220, SwitchStatement = 221, LabeledStatement = 222, ThrowStatement = 223, TryStatement = 224, DebuggerStatement = 225, VariableDeclaration = 226, VariableDeclarationList = 227, FunctionDeclaration = 228, ClassDeclaration = 229, InterfaceDeclaration = 230, TypeAliasDeclaration = 231, EnumDeclaration = 232, ModuleDeclaration = 233, ModuleBlock = 234, CaseBlock = 235, NamespaceExportDeclaration = 236, ImportEqualsDeclaration = 237, ImportDeclaration = 238, ImportClause = 239, NamespaceImport = 240, NamedImports = 241, ImportSpecifier = 242, ExportAssignment = 243, ExportDeclaration = 244, NamedExports = 245, ExportSpecifier = 246, MissingDeclaration = 247, ExternalModuleReference = 248, JsxElement = 249, JsxSelfClosingElement = 250, JsxOpeningElement = 251, JsxClosingElement = 252, JsxAttribute = 253, JsxAttributes = 254, JsxSpreadAttribute = 255, JsxExpression = 256, CaseClause = 257, DefaultClause = 258, HeritageClause = 259, CatchClause = 260, PropertyAssignment = 261, ShorthandPropertyAssignment = 262, SpreadAssignment = 263, EnumMember = 264, SourceFile = 265, Bundle = 266, JSDocTypeExpression = 267, JSDocAllType = 268, JSDocUnknownType = 269, JSDocNullableType = 270, JSDocNonNullableType = 271, JSDocOptionalType = 272, JSDocFunctionType = 273, JSDocVariadicType = 274, JSDocComment = 275, JSDocTag = 276, JSDocAugmentsTag = 277, JSDocClassTag = 278, JSDocParameterTag = 279, JSDocReturnTag = 280, JSDocTypeTag = 281, JSDocTemplateTag = 282, JSDocTypedefTag = 283, JSDocPropertyTag = 284, JSDocTypeLiteral = 285, SyntaxList = 286, NotEmittedStatement = 287, PartiallyEmittedExpression = 288, CommaListExpression = 289, MergeDeclarationMarker = 290, EndOfDeclarationMarker = 291, Count = 292, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, LastCompoundAssignment = 70, FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, LastKeyword = 142, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 158, LastTypeNode = 173, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, LastToken = 142, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 13, FirstTemplateToken = 13, LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 143, FirstJSDocNode = 267, LastJSDocNode = 285, FirstJSDocTagNode = 276, LastJSDocTagNode = 285, } enum NodeFlags { None = 0, Let = 1, Const = 2, NestedNamespace = 4, Synthesized = 8, Namespace = 16, ExportContext = 32, ContainsThis = 64, HasImplicitReturn = 128, HasExplicitReturn = 256, GlobalAugmentation = 512, HasAsyncFunctions = 1024, DisallowInContext = 2048, YieldContext = 4096, DecoratorContext = 8192, AwaitContext = 16384, ThisNodeHasError = 32768, JavaScriptFile = 65536, ThisNodeOrAnySubNodesHasError = 131072, HasAggregatedChildData = 262144, JSDoc = 1048576, BlockScoped = 3, ReachabilityCheckFlags = 384, ReachabilityAndEmitFlags = 1408, ContextFlags = 96256, TypeExcludesFlags = 20480, } 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, } 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, } interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray<Decorator>; modifiers?: ModifiersArray; parent?: Node; } interface JSDocContainer { } 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 | EndOfFileToken; interface NodeArray<T extends Node> extends ReadonlyArray<T>, TextRange { hasTrailingComma?: boolean; } interface Token<TKind extends SyntaxKind> extends Node { kind: TKind; } type DotDotDotToken = Token<SyntaxKind.DotDotDotToken>; type QuestionToken = Token<SyntaxKind.QuestionToken>; type ColonToken = Token<SyntaxKind.ColonToken>; type EqualsToken = Token<SyntaxKind.EqualsToken>; type AsteriskToken = Token<SyntaxKind.AsteriskToken>; type EqualsGreaterThanToken = Token<SyntaxKind.EqualsGreaterThanToken>; type EndOfFileToken = Token<SyntaxKind.EndOfFileToken> & JSDocContainer; type AtToken = Token<SyntaxKind.AtToken>; type ReadonlyToken = Token<SyntaxKind.ReadonlyKeyword>; type AwaitKeywordToken = Token<SyntaxKind.AwaitKeyword>; 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>; type ModifiersArray = NodeArray<Modifier>; interface Identifier extends PrimaryExpression { 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; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } type EntityName = Identifier | QualifiedName; type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; type DeclarationName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | BindingPattern; interface Declaration extends Node { _declarationBrand: any; } interface NamedDeclaration extends Declaration { name?: DeclarationName; } interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } interface ComputedPropertyName extends Node { kind: SyntaxKind.ComputedPropertyName; expression: Expression; } interface Decorator extends Node { kind: SyntaxKind.Decorator; parent?: NamedDeclaration; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent?: DeclarationWithTypeParameters; name: Identifier; constraint?: TypeNode; default?: TypeNode; expression?: Expression; } interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray<TypeParameterDeclaration>; parameters: NodeArray<ParameterDeclaration>; type: TypeNode | undefined; } type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent?: VariableDeclarationList | CatchClause; name: BindingName; type?: TypeNode; initializer?: Expression; } interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray<VariableDeclaration>; } interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent?: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; initializer?: Expression; } interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; questionToken?: QuestionToken; name: PropertyName; type?: TypeNode; initializer?: Expression; } interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrandBrand: any; name?: PropertyName; } type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; equalsToken?: Token<SyntaxKind.EqualsToken>; objectAssignmentInitializer?: Expression; } interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } interface VariableLikeDeclaration extends NamedDeclaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: DeclarationName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray<BindingElement>; } interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray<ArrayBindingElement>; } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; 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 */ interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; body?: Block | Expression; } type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | FunctionExpression | ArrowFunction; type FunctionLike = FunctionLikeDeclaration | FunctionTypeNode | ConstructorTypeNode | IndexSignatureDeclaration | MethodSignature | ConstructSignatureDeclaration | CallSignatureDeclaration; interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.FunctionDeclaration; name?: Identifier; body?: FunctionBody; } interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; parent?: ClassDeclaration | ClassExpression; } interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } interface TypeNode extends Node { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType; } interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; interface TypeReferenceNode extends TypeNode { kind: SyntaxKind.TypeReference; typeName: EntityName; typeArguments?: NodeArray<TypeNode>; } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent?: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; exprName: EntityName; } interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray<TypeElement>; } interface ArrayTypeNode extends TypeNode { kind: SyntaxKind.ArrayType; elementType: TypeNode; } interface TupleTypeNode extends TypeNode { kind: SyntaxKind.TupleType; elementTypes: NodeArray<TypeNode>; } type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; interface UnionTypeNode extends TypeNode { kind: SyntaxKind.UnionType; types: NodeArray<TypeNode>; } interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; types: NodeArray<TypeNode>; } interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; type: TypeNode; } interface TypeOperatorNode extends TypeNode { kind: SyntaxKind.TypeOperator; operator: SyntaxKind.KeyOfKeyword; type: TypeNode; } interface IndexedAccessTypeNode extends TypeNode { kind: SyntaxKind.IndexedAccessType; objectType: TypeNode; indexType: TypeNode; } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; type?: TypeNode; } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; } interface Expression extends Node { _expressionBrand: any; } interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; } interface PartiallyEmittedExpression extends LeftHandSideExpression { kind: SyntaxKind.PartiallyEmittedExpression; expression: Expression; } interface UnaryExpression extends Expression { _unaryExpressionBrand: any; } /** Deprecated, please use UpdateExpression */ type IncrementExpression = UpdateExpression; interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } type PrefixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.TildeToken | SyntaxKind.ExclamationToken; interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } type PostfixUnaryOperator = SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken; interface PostfixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PostfixUnaryExpression; operand: LeftHandSideExpression; operator: PostfixUnaryOperator; } interface LeftHandSideExpression extends UpdateExpression { _leftHandSideExpressionBrand: any; } interface MemberExpression extends LeftHandSideExpression { _memberExpressionBrand: any; } interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } interface SuperExpression extends PrimaryExpression { kind: SyntaxKind.SuperKeyword; } interface ImportExpression extends PrimaryExpression { kind: SyntaxKind.ImportKeyword; } interface DeleteExpression extends UnaryExpression { kind: SyntaxKind.DeleteExpression; expression: UnaryExpression; } interface TypeOfExpression extends UnaryExpression { kind: SyntaxKind.TypeOfExpression; expression: UnaryExpression; } interface VoidExpression extends UnaryExpression { kind: SyntaxKind.VoidExpression; expression: UnaryExpression; } interface AwaitExpression extends UnaryExpression { kind: SyntaxKind.AwaitExpression; expression: UnaryExpression; } interface YieldExpression extends Expression { kind: SyntaxKind.YieldExpression; asteriskToken?: AsteriskToken; expression?: Expression; } type ExponentiationOperator = SyntaxKind.AsteriskAsteriskToken; type MultiplicativeOperator = SyntaxKind.AsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken; type MultiplicativeOperatorOrHigher = ExponentiationOperator | MultiplicativeOperator; type AdditiveOperator = SyntaxKind.PlusToken | SyntaxKind.MinusToken; type AdditiveOperatorOrHigher = MultiplicativeOperatorOrHigher | AdditiveOperator; type ShiftOperator = SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken; type ShiftOperatorOrHigher = AdditiveOperatorOrHigher | ShiftOperator; type RelationalOperator = SyntaxKind.LessThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.InstanceOfKeyword | SyntaxKind.InKeyword; type RelationalOperatorOrHigher = ShiftOperatorOrHigher | RelationalOperator; type EqualityOperator = SyntaxKind.EqualsEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.ExclamationEqualsToken; type EqualityOperatorOrHigher = RelationalOperatorOrHigher | EqualityOperator; type BitwiseOperator = SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken; type BitwiseOperatorOrHigher = EqualityOperatorOrHigher | BitwiseOperator; type LogicalOperator = SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken; type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; 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; type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; type BinaryOperatorToken = Token<BinaryOperator>; interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } type AssignmentOperatorToken = Token<AssignmentOperator>; interface AssignmentExpression<TOperator extends AssignmentOperatorToken> extends BinaryExpression { left: LeftHandSideExpression; operatorToken: TOperator; } interface ObjectDestructuringAssignment extends AssignmentExpression<EqualsToken> { left: ObjectLiteralExpression; } interface ArrayDestructuringAssignment extends AssignmentExpression<EqualsToken> { left: ArrayLiteralExpression; } type DestructuringAssignment = ObjectDestructuringAssignment | ArrayDestructuringAssignment; type BindingOrAssignmentElement = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | OmittedExpression | SpreadElement | ArrayLiteralExpression | ObjectLiteralExpression | AssignmentExpression<EqualsToken> | Identifier | PropertyAccessExpression | ElementAccessExpression; type BindingOrAssignmentElementRestIndicator = DotDotDotToken | SpreadElement | SpreadAssignment; type BindingOrAssignmentElementTarget = BindingOrAssignmentPattern | Expression; type ObjectBindingOrAssignmentPattern = ObjectBindingPattern | ObjectLiteralExpression; type ArrayBindingOrAssignmentPattern = ArrayBindingPattern | ArrayLiteralExpression; type AssignmentPattern = ObjectLiteralExpression | ArrayLiteralExpression; type BindingOrAssignmentPattern = ObjectBindingOrAssignmentPattern | ArrayBindingOrAssignmentPattern; interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; whenTrue: Expression; colonToken: ColonToken; whenFalse: Expression; } type FunctionBody = Block; type ConciseBody = FunctionBody | Expression; interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; } interface LiteralLikeNode extends Node { text: string; isUnterminated?: boolean; hasExtendedUnicodeEscape?: boolean; } interface LiteralExpression extends LiteralLikeNode, PrimaryExpression { _literalExpressionBrand: any; } interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } interface NoSubstitutionTemplateLiteral extends LiteralExpression { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; parent?: TemplateExpression; } interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; parent?: TemplateSpan; } interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; parent?: TemplateSpan; } type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { kind: SyntaxKind.TemplateExpression; head: TemplateHead; templateSpans: NodeArray<TemplateSpan>; } interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; parent?: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } interface ArrayLiteralExpression extends PrimaryExpression { kind: SyntaxKind.ArrayLiteralExpression; elements: NodeArray<Expression>; } 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.) */ interface ObjectLiteralExpressionBase<T extends ObjectLiteralElement> extends PrimaryExpression, Declaration { properties: NodeArray<T>; } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase<ObjectLiteralElementLike> { kind: SyntaxKind.ObjectLiteralExpression; } type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; } interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { _propertyAccessExpressionLikeQualifiedNameBrand?: any; expression: EntityNameExpression; } interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; argumentExpression?: Expression; } interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression; interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray<TypeNode>; arguments: NodeArray<Expression>; } interface SuperCall extends CallExpression { expression: SuperExpression; } interface ImportCall extends CallExpression { expression: ImportExpression; } interface ExpressionWithTypeArguments extends TypeNode { kind: SyntaxKind.ExpressionWithTypeArguments; parent?: HeritageClause; expression: LeftHandSideExpression; typeArguments?: NodeArray<TypeNode>; } interface NewExpression extends PrimaryExpression, Declaration { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray<TypeNode>; arguments?: NodeArray<Expression>; } interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; tag: LeftHandSideExpression; template: TemplateLiteral; } type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator | JsxOpeningLikeElement; interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } type AssertionExpression = TypeAssertion | AsExpression; interface NonNullExpression extends LeftHandSideExpression { kind: SyntaxKind.NonNullExpression; expression: Expression; } interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; keywordToken: SyntaxKind.NewKeyword; name: Identifier; } interface JsxElement extends PrimaryExpression { kind: SyntaxKind.JsxElement; openingElement: JsxOpeningElement; children: NodeArray<JsxChild>; closingElement: JsxClosingElement; } type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxAttributes extends ObjectLiteralExpressionBase<JsxAttributeLike> { parent?: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; parent?: JsxElement; tagName: JsxTagNameExpression; attributes: JsxAttributes; } interface JsxSelfClosingElement extends PrimaryExpression { kind: SyntaxKind.JsxSelfClosingElement; tagName: JsxTagNameExpression; attributes: JsxAttributes; } interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; parent?: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; parent?: JsxAttributes; expression: Expression; } interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; parent?: JsxElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; parent?: JsxElement | JsxAttributeLike; dotDotDotToken?: Token<SyntaxKind.DotDotDotToken>; expression?: Expression; } interface JsxText extends Node { kind: SyntaxKind.JsxText; containsOnlyWhiteSpaces: boolean; parent?: JsxElement; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { _statementBrand: any; } interface NotEmittedStatement extends Statement { kind: SyntaxKind.NotEmittedStatement; } /** * A list of comma-seperated expressions. This node is only created by transformations. */ interface CommaListExpression extends Expression { kind: SyntaxKind.CommaListExpression; elements: NodeArray<Expression>; } interface EmptyStatement extends Statement { kind: SyntaxKind.EmptyStatement; } interface DebuggerStatement extends Statement { kind: SyntaxKind.DebuggerStatement; } interface MissingDeclaration extends DeclarationStatement, ClassElement, ObjectLiteralElement, TypeElement { kind: SyntaxKind.MissingDeclaration; name?: Identifier; } type BlockLike = SourceFile | Block | ModuleBlock | CaseOrDefaultClause; interface Block extends Statement { kind: SyntaxKind.Block; statements: NodeArray<Statement>; } interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } interface IfStatement extends Statement { kind: SyntaxKind.IfStatement; expression: Expression; thenStatement: Statement; elseStatement?: Statement; } interface IterationStatement extends Statement { statement: Statement; } interface DoStatement extends IterationStatement { kind: SyntaxKind.DoStatement; expression: Expression; } interface WhileStatement extends IterationStatement { kind: SyntaxKind.WhileStatement; expression: Expression; } type ForInitializer = VariableDeclarationList | Expression; interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } type ForInOrOfStatement = ForInStatement | ForOfStatement; interface ForInStatement extends IterationStatement { kind: SyntaxKind.ForInStatement; initializer: ForInitializer; expression: Expression; } interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } interface BreakStatement extends Statement { kind: SyntaxKind.BreakStatement; label?: Identifier; } interface ContinueStatement extends Statement { kind: SyntaxKind.ContinueStatement; label?: Identifier; } type BreakOrContinueStatement = BreakStatement | ContinueStatement; interface ReturnStatement extends Statement { kind: SyntaxKind.ReturnStatement; expression?: Expression; } interface WithStatement extends Statement { kind: SyntaxKind.WithStatement; expression: Expression; statement: Statement; } interface SwitchStatement extends Statement { kind: SyntaxKind.SwitchStatement; expression: Expression; caseBlock: CaseBlock; possiblyExhaustive?: boolean; } interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; parent?: SwitchStatement; clauses: NodeArray<CaseOrDefaultClause>; } interface CaseClause extends Node { kind: SyntaxKind.CaseClause; parent?: CaseBlock; expression: Expression; statements: NodeArray<Statement>; } interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; parent?: CaseBlock; statements: NodeArray<Statement>; } type CaseOrDefaultClause = CaseClause | DefaultClause; interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; } interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; expression: Expression; } interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; tryBlock: Block; catchClause?: CatchClause; finallyBlock?: Block; } interface CatchClause extends Node { kind: SyntaxKind.CatchClause; parent?: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray<TypeParameterDeclaration>; heritageClauses?: NodeArray<HeritageClause>; members: NodeArray<ClassElement>; } interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; name?: Identifier; } interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } type ClassLikeDeclaration = ClassDeclaration | ClassExpression; interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } interface TypeElement extends NamedDeclaration { _typeElementBrand: any;