UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

1,541 lines 146 kB
export declare 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, UniqueKeyword = 140, FromKeyword = 141, GlobalKeyword = 142, OfKeyword = 143, QualifiedName = 144, ComputedPropertyName = 145, TypeParameter = 146, Parameter = 147, Decorator = 148, PropertySignature = 149, PropertyDeclaration = 150, MethodSignature = 151, MethodDeclaration = 152, Constructor = 153, GetAccessor = 154, SetAccessor = 155, CallSignature = 156, ConstructSignature = 157, IndexSignature = 158, TypePredicate = 159, TypeReference = 160, FunctionType = 161, ConstructorType = 162, TypeQuery = 163, TypeLiteral = 164, ArrayType = 165, TupleType = 166, UnionType = 167, IntersectionType = 168, ParenthesizedType = 169, ThisType = 170, TypeOperator = 171, IndexedAccessType = 172, MappedType = 173, LiteralType = 174, ObjectBindingPattern = 175, ArrayBindingPattern = 176, BindingElement = 177, ArrayLiteralExpression = 178, ObjectLiteralExpression = 179, PropertyAccessExpression = 180, ElementAccessExpression = 181, CallExpression = 182, NewExpression = 183, TaggedTemplateExpression = 184, TypeAssertionExpression = 185, ParenthesizedExpression = 186, FunctionExpression = 187, ArrowFunction = 188, DeleteExpression = 189, TypeOfExpression = 190, VoidExpression = 191, AwaitExpression = 192, PrefixUnaryExpression = 193, PostfixUnaryExpression = 194, BinaryExpression = 195, ConditionalExpression = 196, TemplateExpression = 197, YieldExpression = 198, SpreadElement = 199, ClassExpression = 200, OmittedExpression = 201, ExpressionWithTypeArguments = 202, AsExpression = 203, NonNullExpression = 204, MetaProperty = 205, TemplateSpan = 206, SemicolonClassElement = 207, Block = 208, VariableStatement = 209, EmptyStatement = 210, ExpressionStatement = 211, IfStatement = 212, DoStatement = 213, WhileStatement = 214, ForStatement = 215, ForInStatement = 216, ForOfStatement = 217, ContinueStatement = 218, BreakStatement = 219, ReturnStatement = 220, WithStatement = 221, SwitchStatement = 222, LabeledStatement = 223, ThrowStatement = 224, TryStatement = 225, DebuggerStatement = 226, VariableDeclaration = 227, VariableDeclarationList = 228, FunctionDeclaration = 229, ClassDeclaration = 230, InterfaceDeclaration = 231, TypeAliasDeclaration = 232, EnumDeclaration = 233, ModuleDeclaration = 234, ModuleBlock = 235, CaseBlock = 236, NamespaceExportDeclaration = 237, ImportEqualsDeclaration = 238, ImportDeclaration = 239, ImportClause = 240, NamespaceImport = 241, NamedImports = 242, ImportSpecifier = 243, ExportAssignment = 244, ExportDeclaration = 245, NamedExports = 246, ExportSpecifier = 247, MissingDeclaration = 248, ExternalModuleReference = 249, JsxElement = 250, JsxSelfClosingElement = 251, JsxOpeningElement = 252, JsxClosingElement = 253, JsxFragment = 254, JsxOpeningFragment = 255, JsxClosingFragment = 256, JsxAttribute = 257, JsxAttributes = 258, JsxSpreadAttribute = 259, JsxExpression = 260, CaseClause = 261, DefaultClause = 262, HeritageClause = 263, CatchClause = 264, PropertyAssignment = 265, ShorthandPropertyAssignment = 266, SpreadAssignment = 267, EnumMember = 268, SourceFile = 269, Bundle = 270, JSDocTypeExpression = 271, JSDocAllType = 272, JSDocUnknownType = 273, JSDocNullableType = 274, JSDocNonNullableType = 275, JSDocOptionalType = 276, JSDocFunctionType = 277, JSDocVariadicType = 278, JSDocComment = 279, JSDocTypeLiteral = 280, JSDocTag = 281, JSDocAugmentsTag = 282, JSDocClassTag = 283, JSDocParameterTag = 284, JSDocReturnTag = 285, JSDocTypeTag = 286, JSDocTemplateTag = 287, JSDocTypedefTag = 288, JSDocPropertyTag = 289, SyntaxList = 290, NotEmittedStatement = 291, PartiallyEmittedExpression = 292, CommaListExpression = 293, MergeDeclarationMarker = 294, EndOfDeclarationMarker = 295, Count = 296, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, LastCompoundAssignment = 70, FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, LastKeyword = 143, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, FirstTypeNode = 159, LastTypeNode = 174, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, LastToken = 143, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 13, FirstTemplateToken = 13, LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, FirstNode = 144, FirstJSDocNode = 271, LastJSDocNode = 289, FirstJSDocTagNode = 281, LastJSDocTagNode = 289, } export declare enum TypeFormatFlags { None = 0, NoTruncation = 1, WriteArrayAsGenericType = 2, WriteDefaultSymbolWithoutName = 4, UseStructuralFallback = 8, WriteTypeArgumentsOfSignature = 32, UseFullyQualifiedType = 64, SuppressAnyReturnType = 256, MultilineObjectLiterals = 1024, WriteClassExpressionAsTypeLiteral = 2048, UseTypeOfFunction = 4096, OmitParameterModifiers = 8192, UseAliasDefinedOutsideCurrentScope = 16384, AllowUniqueESSymbolType = 1048576, AddUndefined = 131072, WriteArrowStyleSignature = 262144, InArrayType = 524288, InElementType = 2097152, InFirstTypeArgument = 4194304, InTypeAlias = 8388608, /** * @deprecated */ WriteOwnNameForAnyLike = 0, NodeBuilderFlagsMask = 9469295, } export declare enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, Property = 4, EnumMember = 8, Function = 16, Class = 32, Interface = 64, ConstEnum = 128, RegularEnum = 256, ValueModule = 512, NamespaceModule = 1024, TypeLiteral = 2048, ObjectLiteral = 4096, Method = 8192, Constructor = 16384, GetAccessor = 32768, SetAccessor = 65536, Signature = 131072, TypeParameter = 262144, TypeAlias = 524288, ExportValue = 1048576, Alias = 2097152, Prototype = 4194304, ExportStar = 8388608, Optional = 16777216, Transient = 33554432, JSContainer = 67108864, Enum = 384, Variable = 3, Value = 107455, Type = 793064, Namespace = 1920, Module = 1536, Accessor = 98304, FunctionScopedVariableExcludes = 107454, BlockScopedVariableExcludes = 107455, ParameterExcludes = 107455, PropertyExcludes = 0, EnumMemberExcludes = 900095, FunctionExcludes = 106927, ClassExcludes = 899519, InterfaceExcludes = 792968, RegularEnumExcludes = 899327, ConstEnumExcludes = 899967, ValueModuleExcludes = 106639, NamespaceModuleExcludes = 0, MethodExcludes = 99263, GetAccessorExcludes = 41919, SetAccessorExcludes = 74687, TypeParameterExcludes = 530920, TypeAliasExcludes = 793064, AliasExcludes = 2097152, ModuleMember = 2623475, ExportHasLocal = 944, HasExports = 1952, HasMembers = 6240, BlockScoped = 418, PropertyOrAccessor = 98308, ClassMember = 106500, } export declare enum TypeFlags { Any = 1, String = 2, Number = 4, Boolean = 8, Enum = 16, StringLiteral = 32, NumberLiteral = 64, BooleanLiteral = 128, EnumLiteral = 256, ESSymbol = 512, UniqueESSymbol = 1024, Void = 2048, Undefined = 4096, Null = 8192, Never = 16384, TypeParameter = 32768, Object = 65536, Union = 131072, Intersection = 262144, Index = 524288, IndexedAccess = 1048576, NonPrimitive = 33554432, MarkerType = 134217728, Literal = 224, Unit = 13536, StringOrNumberLiteral = 96, PossiblyFalsy = 14574, StringLike = 524322, NumberLike = 84, BooleanLike = 136, EnumLike = 272, ESSymbolLike = 1536, UnionOrIntersection = 393216, StructuredType = 458752, StructuredOrTypeVariable = 2064384, TypeVariable = 1081344, Narrowable = 35620607, NotUnionOrUnit = 33620481, } export declare enum ObjectFlags { Class = 1, Interface = 2, Reference = 4, Tuple = 8, Anonymous = 16, Mapped = 32, Instantiated = 64, ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, ContainsSpread = 1024, ReverseMapped = 2048, ClassOrInterface = 3, } export declare enum DiagnosticCategory { Warning = 0, Error = 1, Message = 2, } export declare enum ModuleResolutionKind { Classic = 1, NodeJs = 2, } export declare enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, UMD = 3, System = 4, ES2015 = 5, ESNext = 6, } export declare enum JsxEmit { None = 0, Preserve = 1, React = 2, ReactNative = 3, } export declare enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } export declare enum ScriptKind { Unknown = 0, JS = 1, JSX = 2, TS = 3, TSX = 4, External = 5, JSON = 6, } export declare enum ScriptTarget { ES3 = 0, ES5 = 1, ES2015 = 2, ES2016 = 3, ES2017 = 4, ES2018 = 5, ESNext = 6, Latest = 6, } export declare enum LanguageVariant { Standard = 0, JSX = 1, } export declare enum EmitHint { SourceFile = 0, Expression = 1, IdentifierName = 2, MappedTypeParameter = 3, Unspecified = 4, } /** * 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. */ export interface MapLike<T> { [index: string]: T; } export interface CompilerOptions { [option: string]: ts.CompilerOptionsValue | ts.JsonSourceFile | undefined; allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; alwaysStrict?: boolean; baseUrl?: string; charset?: string; checkJs?: boolean; declaration?: boolean; declarationDir?: string; disableSizeLimit?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; importHelpers?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; jsx?: JsxEmit; lib?: string[]; locale?: string; mapRoot?: string; maxNodeModuleJsDepth?: number; module?: ModuleKind; moduleResolution?: ModuleResolutionKind; newLine?: NewLineKind; noEmit?: boolean; noEmitHelpers?: boolean; noEmitOnError?: boolean; noErrorTruncation?: boolean; noFallthroughCasesInSwitch?: boolean; noImplicitAny?: boolean; noImplicitReturns?: boolean; noImplicitThis?: boolean; noStrictGenericChecks?: boolean; noUnusedLocals?: boolean; noUnusedParameters?: boolean; noImplicitUseStrict?: boolean; noLib?: boolean; noResolve?: boolean; out?: string; outDir?: string; outFile?: string; paths?: MapLike<string[]>; preserveConstEnums?: boolean; preserveSymlinks?: boolean; project?: string; reactNamespace?: string; jsxFactory?: string; removeComments?: boolean; rootDir?: string; rootDirs?: string[]; skipLibCheck?: boolean; skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; strict?: boolean; strictFunctionTypes?: boolean; strictNullChecks?: boolean; strictPropertyInitialization?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; target?: ScriptTarget; traceResolution?: boolean; types?: string[]; /** * Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; } export declare namespace ts { /** * ES6 Map interface, only read methods included. */ interface ReadonlyMap<T> { size: number; get(key: string): T | undefined; has(key: string): boolean; forEach(action: (value: T, key: string) => void): void; 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; } interface TextRange { pos: number; end: number; } interface Node extends TextRange { kind: SyntaxKind; flags: NodeFlags; decorators?: NodeArray<Decorator>; modifiers?: ModifiersArray; parent?: Node; } interface JSDocContainer { } interface NodeArray<T extends Node> extends ReadonlyArray<T>, TextRange { hasTrailingComma?: boolean; } interface Token<TKind extends SyntaxKind> extends Node { kind: TKind; } 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; } interface TransientIdentifier extends Identifier { resolvedSymbol: Symbol; } interface QualifiedName extends Node { kind: SyntaxKind.QualifiedName; left: EntityName; right: Identifier; } 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; } interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent?: VariableDeclarationList | CatchClause; name: BindingName; exclamationToken?: ExclamationToken; 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; name: PropertyName; questionToken?: QuestionToken; exclamationToken?: ExclamationToken; type?: TypeNode; initializer?: Expression; } interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrandBrand: any; name?: PropertyName; } 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 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>; } /** * 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; } 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?: ClassLikeDeclaration; 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?: ClassLikeDeclaration; } interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent?: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent?: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent?: ClassLikeDeclaration | 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; } interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType; } interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } 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>; } 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 | SyntaxKind.UniqueKeyword; 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; } interface UpdateExpression extends UnaryExpression { _updateExpressionBrand: any; } interface PrefixUnaryExpression extends UpdateExpression { kind: SyntaxKind.PrefixUnaryExpression; operator: PrefixUnaryOperator; operand: UnaryExpression; } 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; } interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; right: Expression; } 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; } interface ConditionalExpression extends Expression { kind: SyntaxKind.ConditionalExpression; condition: Expression; questionToken: QuestionToken; whenTrue: Expression; colonToken: ColonToken; whenFalse: 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; name: never; } 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; } 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; } 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; } 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; } interface AsExpression extends Expression { kind: SyntaxKind.AsExpression; expression: Expression; type: TypeNode; } interface TypeAssertion extends UnaryExpression { kind: SyntaxKind.TypeAssertionExpression; type: TypeNode; expression: UnaryExpression; } 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; } 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 JsxFragment extends PrimaryExpression { kind: SyntaxKind.JsxFragment; openingFragment: JsxOpeningFragment; children: NodeArray<JsxChild>; closingFragment: JsxClosingFragment; } interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; parent?: JsxFragment; } interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; parent?: JsxFragment; } 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; } 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; } 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; } interface ForStatement extends IterationStatement { kind: SyntaxKind.ForStatement; initializer?: ForInitializer; condition?: Expression; incrementor?: Expression; } 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; } 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>; } 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; } 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; } interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; } interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray<TypeParameterDeclaration>; heritageClauses?: NodeArray<HeritageClause>; members: NodeArray<TypeElement>; } interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent?: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray<ExpressionWithTypeArguments>; } interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray<TypeParameterDeclaration>; type: TypeNode; } interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent?: EnumDeclaration; name: PropertyName; initializer?: Expression; } interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray<EnumMember>; } interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } interface NamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: NamespaceBody; } interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; body: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; parent?: ModuleDeclaration; statements: NodeArray<Statement>; } /** * One of: * - import x = require("mod"); * - import x = M.x; */ interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; parent?: ImportEqualsDeclaration; expression?: Expression; } interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; parent?: SourceFile | ModuleBlock; importClause?: ImportClause; /** * If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent?: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent?: ImportClause; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; } interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; parent?: SourceFile | ModuleBlock; /** * from "foo";` */ exportClause?: NamedExports; /** * If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } interface NamedImports extends Node { kind: SyntaxKind.NamedImports; parent?: ImportClause; elements: NodeArray<ImportSpecifier>; } interface NamedExports extends Node { kind: SyntaxKind.NamedExports; parent?: ExportDeclaration; elements: NodeArray<ExportSpecifier>; } interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent?: NamedImports; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent?: NamedExports; propertyName?: Identifier; name: Identifier; } interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; parent?: SourceFile; isExportEquals?: boolean; expression: Expression; } interface FileReference extends TextRange { fileName: string; } interface CheckJsDirective extends TextRange { enabled: boolean; } interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; kind: CommentKind; } interface SynthesizedComment extends CommentRange { text: string; p