sucrase
Version:
Super-fast alternative to Babel for when you can target modern JS runtimes
815 lines (814 loc) • 28.2 kB
TypeScript
import { Token } from "./tokenizer";
import { Scope } from "./tokenizer/state";
import { SourceLocation } from "./util/location";
export interface NodeBase {
start: number;
end: number;
loc: SourceLocation;
range: [number, number];
type: string;
extra: {
[key: string]: any;
};
}
export declare type Node = NodeBase & {
[key: string]: any;
};
export declare type Expression = Node;
export declare type Statement = Node;
export declare type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern;
export declare type Declaration = VariableDeclaration | ClassDeclaration | FunctionDeclaration | TsInterfaceDeclaration | TsTypeAliasDeclaration | TsEnumDeclaration | TsModuleDeclaration;
export declare type DeclarationBase = NodeBase & {
declare?: true;
};
export declare type HasDecorators = NodeBase & {
decorators?: ReadonlyArray<Decorator>;
};
export declare type Identifier = PatternBase & {
type: "Identifier";
name: string;
__clone(): Identifier;
optional?: true | null;
};
export declare type PrivateName = NodeBase & {
type: "PrivateName";
id: Identifier;
};
export declare type Literal = RegExpLiteral | NullLiteral | StringLiteral | BooleanLiteral | NumericLiteral;
export declare type RegExpLiteral = NodeBase & {
type: "RegExpLiteral";
pattern: string;
flags: string;
};
export declare type NullLiteral = NodeBase & {
type: "NullLiteral";
};
export declare type StringLiteral = NodeBase & {
type: "StringLiteral";
value: string;
};
export declare type BooleanLiteral = NodeBase & {
type: "BooleanLiteral";
value: boolean;
};
export declare type NumericLiteral = NodeBase & {
type: "NumericLiteral";
value: number;
};
export declare type BigIntLiteral = NodeBase & {
type: "BigIntLiteral";
value: number;
};
export declare type File = {
tokens: Array<Token>;
scopes: Array<Scope>;
};
export declare type Function = NormalFunction | ArrowFunctionExpression | ObjectMethod | ClassMethod;
export declare type NormalFunction = FunctionDeclaration | FunctionExpression;
export declare type BodilessFunctionOrMethodBase = HasDecorators & {
id: Identifier | null;
params: ReadonlyArray<Pattern | TSParameterProperty>;
body: BlockStatement;
generator: boolean;
async: boolean;
expression: boolean;
typeParameters?: TypeParameterDeclarationBase | null;
returnType?: TypeAnnotationBase | null;
};
export declare type BodilessFunctionBase = BodilessFunctionOrMethodBase & {
id: Identifier | null;
};
export declare type FunctionBase = BodilessFunctionBase & {
body: BlockStatement;
};
export declare type ExpressionStatement = NodeBase & {
type: "ExpressionStatement";
expression: Expression;
};
export declare type BlockStatement = NodeBase & {
type: "BlockStatement";
body: Array<Statement>;
directives: ReadonlyArray<Directive>;
};
export declare type EmptyStatement = NodeBase & {
type: "EmptyStatement";
};
export declare type DebuggerStatement = NodeBase & {
type: "DebuggerStatement";
};
export declare type WithStatement = NodeBase & {
type: "WithStatement";
object: Expression;
body: Statement;
};
export declare type ReturnStatement = NodeBase & {
type: "ReturnStatement";
argument: Expression | null;
};
export declare type LabeledStatement = NodeBase & {
type: "LabeledStatement";
label: Identifier;
body: Statement;
};
export declare type BreakStatement = NodeBase & {
type: "BreakStatement";
label: Identifier | null;
};
export declare type ContinueStatement = NodeBase & {
type: "ContinueStatement";
label: Identifier | null;
};
export declare type IfStatement = NodeBase & {
type: "IfStatement";
test: Expression;
consequent: Statement;
alternate: Statement | null;
};
export declare type SwitchStatement = NodeBase & {
type: "SwitchStatement";
discriminant: Expression;
cases: ReadonlyArray<SwitchCase>;
};
export declare type SwitchCase = NodeBase & {
type: "SwitchCase";
test: Expression | null;
consequent: ReadonlyArray<Statement>;
};
export declare type ThrowStatement = NodeBase & {
type: "ThrowStatement";
argument: Expression;
};
export declare type TryStatement = NodeBase & {
type: "TryStatement";
block: BlockStatement;
handler: CatchClause | null;
finalizer: BlockStatement | null;
guardedHandlers: ReadonlyArray<never>;
};
export declare type CatchClause = NodeBase & {
type: "CatchClause";
param: Pattern;
body: BlockStatement;
};
export declare type WhileStatement = NodeBase & {
type: "WhileStatement";
test: Expression;
body: Statement;
};
export declare type DoWhileStatement = NodeBase & {
type: "DoWhileStatement";
body: Statement;
test: Expression;
};
export declare type ForLike = ForStatement | ForInOf;
export declare type ForStatement = NodeBase & {
type: "ForStatement";
init: VariableDeclaration | Expression | null;
test: Expression | null;
update: Expression | null;
body: Statement;
};
export declare type ForInOf = ForInStatement | ForOfStatement;
export declare type ForInOfBase = NodeBase & {
type: "ForInStatement";
left: VariableDeclaration | Expression;
right: Expression;
body: Statement;
};
export declare type ForInStatement = ForInOfBase & {
type: "ForInStatement";
await: boolean;
};
export declare type ForOfStatement = ForInOfBase & {
type: "ForOfStatement";
await: boolean;
};
export declare type OptFunctionDeclaration = FunctionBase & DeclarationBase & {
type: "FunctionDeclaration";
};
export declare type FunctionDeclaration = OptFunctionDeclaration & {
id: Identifier;
};
export declare type VariableDeclaration = DeclarationBase & HasDecorators & {
type: "VariableDeclaration";
declarations: ReadonlyArray<VariableDeclarator>;
kind: "var" | "let" | "const";
};
export declare type VariableDeclarator = NodeBase & {
type: "VariableDeclarator";
id: Pattern;
init: Expression | null;
};
export declare type Decorator = NodeBase & {
type: "Decorator";
expression: Expression;
};
export declare type Directive = NodeBase & {
type: "Directive";
value: DirectiveLiteral;
};
export declare type DirectiveLiteral = StringLiteral & {
type: "DirectiveLiteral";
};
export declare type Super = NodeBase & {
type: "Super";
};
export declare type Import = NodeBase & {
type: "Import";
};
export declare type ThisExpression = NodeBase & {
type: "ThisExpression";
};
export declare type ArrowFunctionExpression = FunctionBase & {
type: "ArrowFunctionExpression";
body: BlockStatement | Expression;
};
export declare type YieldExpression = NodeBase & {
type: "YieldExpression";
argument: Expression | null;
delegate: boolean;
};
export declare type AwaitExpression = NodeBase & {
type: "AwaitExpression";
argument: Expression | null;
};
export declare type ArrayExpression = NodeBase & {
type: "ArrayExpression";
elements: ReadonlyArray<Expression | SpreadElement | null>;
};
export declare type ObjectExpression = NodeBase & {
type: "ObjectExpression";
properties: ReadonlyArray<ObjectProperty | ObjectMethod | SpreadElement>;
};
export declare type ObjectOrClassMember = ClassMethod | ClassProperty | ObjectMember;
export declare type ObjectMember = ObjectProperty | ObjectMethod;
export declare type ObjectMemberBase = NodeBase & {
key: Expression;
computed: boolean;
value: Expression;
decorators: ReadonlyArray<Decorator>;
kind?: "get" | "set" | "method" | "init";
method: boolean;
variance?: FlowVariance | null;
};
export declare type ObjectProperty = ObjectMemberBase & {
type: "ObjectProperty";
shorthand: boolean;
};
export declare type ObjectMethod = ObjectMemberBase & MethodBase & {
type: "ObjectMethod";
kind: "get" | "set" | "method" | "init";
};
export declare type FunctionExpression = MethodBase & {
kind?: void;
type: "FunctionExpression";
};
export declare type UnaryExpression = NodeBase & {
type: "UnaryExpression";
operator: UnaryOperator;
prefix: boolean;
argument: Expression;
};
export declare type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete" | "throw";
export declare type UpdateExpression = NodeBase & {
type: "UpdateExpression";
operator: UpdateOperator;
argument: Expression;
prefix: boolean;
};
export declare type UpdateOperator = "++" | "--";
export declare type BinaryExpression = NodeBase & {
type: "BinaryExpression";
operator: BinaryOperator;
left: Expression;
right: Expression;
};
export declare type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in" | "instanceof";
export declare type AssignmentExpression = NodeBase & {
type: "AssignmentExpression";
operator: AssignmentOperator;
left: Pattern | Expression;
right: Expression;
};
export declare type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=";
export declare type LogicalExpression = NodeBase & {
type: "LogicalExpression";
operator: LogicalOperator;
left: Expression;
right: Expression;
};
export declare type LogicalOperator = "||" | "&&";
export declare type SpreadElement = NodeBase & {
type: "SpreadElement";
argument: Expression;
};
export declare type MemberExpression = NodeBase & {
type: "MemberExpression";
object: Expression | Super;
property: Expression;
computed: boolean;
};
export declare type BindExpression = NodeBase & {
type: "BindExpression";
object: ReadonlyArray<Expression | null>;
callee: ReadonlyArray<Expression>;
};
export declare type ConditionalExpression = NodeBase & {
type: "ConditionalExpression";
test: Expression;
alternate: Expression;
consequent: Expression;
};
export declare type CallOrNewBase = NodeBase & {
callee: Expression | Super | Import;
arguments: Array<Expression | SpreadElement>;
typeParameters?: TypeParameterInstantiationBase | null;
};
export declare type CallExpression = CallOrNewBase & {
type: "CallExpression";
};
export declare type NewExpression = CallOrNewBase & {
type: "NewExpression";
optional?: boolean;
};
export declare type SequenceExpression = NodeBase & {
type: "SequenceExpression";
expressions: ReadonlyArray<Expression>;
};
export declare type TemplateLiteral = NodeBase & {
type: "TemplateLiteral";
quasis: ReadonlyArray<TemplateElement>;
expressions: ReadonlyArray<Expression>;
};
export declare type TaggedTmplateExpression = NodeBase & {
type: "TaggedTemplateExpression";
tag: Expression;
quasi: TemplateLiteral;
};
export declare type TemplateElement = NodeBase & {
type: "TemplateElement";
tail: boolean;
value: {
cooked: string;
raw: string;
};
};
export declare type Accessibility = "public" | "protected" | "private";
export declare type PatternBase = HasDecorators & {
typeAnnotation?: TypeAnnotationBase | null;
};
export declare type AssignmentProperty = ObjectProperty & {
value: Pattern;
};
export declare type ObjectPattern = PatternBase & {
type: "ObjectPattern";
properties: ReadonlyArray<AssignmentProperty | RestElement>;
};
export declare type ArrayPattern = PatternBase & {
type: "ArrayPattern";
elements: ReadonlyArray<Pattern | null>;
};
export declare type RestElement = PatternBase & {
type: "RestElement";
argument: Pattern;
};
export declare type AssignmentPattern = PatternBase & {
type: "AssignmentPattern";
left: Pattern;
right: Expression;
};
export declare type Class = ClassDeclaration | ClassExpression;
export declare type ClassBase = HasDecorators & {
id: Identifier | null;
superClass: Expression | null;
body: ClassBody;
decorators: ReadonlyArray<Decorator>;
typeParameters?: TypeParameterDeclarationBase | null;
superTypeParameters?: TypeParameterInstantiationBase | null;
implements?: ReadonlyArray<TsExpressionWithTypeArguments> | null | ReadonlyArray<FlowClassImplements>;
};
export declare type ClassBody = NodeBase & {
type: "ClassBody";
body: Array<ClassMember | TsIndexSignature>;
};
export declare type ClassMemberBase = NodeBase & HasDecorators & {
static: boolean;
computed: boolean;
accessibility?: Accessibility | null;
abstract?: true | null;
optional?: true | null;
};
export declare type ClassMember = ClassMethod | ClassPrivateMethod | ClassProperty | ClassPrivateProperty;
export declare type MethodLike = ObjectMethod | FunctionExpression | ClassMethod | ClassPrivateMethod | TSDeclareMethod;
export declare type MethodBase = FunctionBase & {
kind: MethodKind;
};
export declare type MethodKind = "constructor" | "method" | "get" | "set" | "init";
export declare type ClassMethodOrDeclareMethodCommon = ClassMemberBase & {
key: Expression;
kind: MethodKind;
static: boolean;
decorators: ReadonlyArray<Decorator>;
};
export declare type ClassMethod = MethodBase & ClassMethodOrDeclareMethodCommon & {
type: "ClassMethod";
variance?: FlowVariance | null;
};
export declare type ClassPrivateMethod = NodeBase & ClassMethodOrDeclareMethodCommon & MethodBase & {
type: "ClassPrivateMethod";
key: PrivateName;
computed: false;
variance?: FlowVariance | null;
};
export declare type ClassProperty = ClassMemberBase & {
type: "ClassProperty";
key: Expression;
value: Expression | null;
typeAnnotation?: TypeAnnotationBase | null;
variance?: FlowVariance | null;
readonly?: true;
};
export declare type ClassPrivateProperty = NodeBase & {
type: "ClassPrivateProperty";
key: PrivateName;
value: Expression | null;
static: boolean;
computed: false;
};
export declare type OptClassDeclaration = ClassBase & DeclarationBase & HasDecorators & {
type: "ClassDeclaration";
abstract?: true | null;
};
export declare type ClassDeclaration = OptClassDeclaration & {
id: Identifier;
};
export declare type ClassExpression = ClassBase & {
type: "ClassExpression";
};
export declare type MetaProperty = NodeBase & {
type: "MetaProperty";
meta: Identifier;
property: Identifier;
};
export declare type ModuleDeclaration = AnyImport | AnyExport;
export declare type AnyImport = ImportDeclaration | TsImportEqualsDeclaration;
export declare type AnyExport = ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration | TsExportAssignment;
export declare type ModuleSpecifier = NodeBase & {
local: Identifier;
};
export declare type ImportDeclaration = NodeBase & {
type: "ImportDeclaration";
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
source: Literal;
importKind?: "type" | "typeof" | "value";
};
export declare type ImportSpecifier = ModuleSpecifier & {
type: "ImportSpecifier";
imported: Identifier;
};
export declare type ImportDefaultSpecifier = ModuleSpecifier & {
type: "ImportDefaultSpecifier";
};
export declare type ImportNamespaceSpecifier = ModuleSpecifier & {
type: "ImportNamespaceSpecifier";
};
export declare type ExportNamedDeclaration = NodeBase & {
type: "ExportNamedDeclaration";
declaration: Declaration | null;
specifiers: ReadonlyArray<ExportSpecifier>;
source: Literal | null;
exportKind?: "type" | "value";
};
export declare type ExportSpecifier = NodeBase & {
type: "ExportSpecifier";
exported: Identifier;
local: Identifier;
};
export declare type ExportDefaultDeclaration = NodeBase & {
type: "ExportDefaultDeclaration";
declaration: OptFunctionDeclaration | OptTSDeclareFunction | OptClassDeclaration | Expression;
};
export declare type ExportAllDeclaration = NodeBase & {
type: "ExportAllDeclaration";
source: Literal;
exportKind?: "type" | "value";
};
export declare type JSXIdentifier = Node;
export declare type JSXNamespacedName = Node;
export declare type JSXMemberExpression = Node;
export declare type JSXEmptyExpression = Node;
export declare type JSXSpreadChild = Node;
export declare type JSXExpressionContainer = Node;
export declare type JSXAttribute = Node;
export declare type JSXOpeningElement = Node;
export declare type JSXClosingElement = Node;
export declare type JSXElement = Node;
export declare type JSXOpeningFragment = Node;
export declare type JSXClosingFragment = Node;
export declare type JSXFragment = Node;
export declare type TypeAnnotationBase = NodeBase & {
typeAnnotation: Node;
};
export declare type TypeAnnotation = NodeBase & {
type: "TypeAnnotation";
typeAnnotation: FlowTypeAnnotation;
};
export declare type TsTypeAnnotation = NodeBase & {
type: "TSTypeAnnotation";
typeAnnotation: TsType;
};
export declare type TypeParameterDeclarationBase = NodeBase & {
params: ReadonlyArray<TypeParameterBase>;
};
export declare type TypeParameterDeclaration = TypeParameterDeclarationBase & {
type: "TypeParameterDeclaration";
params: ReadonlyArray<TypeParameter>;
};
export declare type TsTypeParameterDeclaration = TypeParameterDeclarationBase & {
type: "TsTypeParameterDeclaration";
params: ReadonlyArray<TsTypeParameter>;
};
export declare type TypeParameterBase = NodeBase & {
name: string;
};
export declare type TypeParameter = TypeParameterBase & {
type: "TypeParameter";
};
export declare type TsTypeParameter = TypeParameterBase & {
type: "TSTypeParameter";
constraint?: TsType;
default?: TsType;
};
export declare type TypeParameterInstantiationBase = NodeBase & {
params: ReadonlyArray<Node>;
};
export declare type TypeParameterInstantiation = TypeParameterInstantiationBase & {
type: "TypeParameterInstantiation";
params: ReadonlyArray<FlowType>;
};
export declare type TsTypeParameterInstantiation = TypeParameterInstantiationBase & {
type: "TSTypeParameterInstantiation";
params: ReadonlyArray<TsType>;
};
export declare type TypeCastExpressionBase = NodeBase & {
expression: Expression;
typeAnnotation: TypeAnnotationBase;
};
export declare type TypeCastExpression = NodeBase & {
type: "TypeCastExpression";
expression: Expression;
typeAnnotation: TypeAnnotation;
};
export declare type TsTypeCastExpression = NodeBase & {
type: "TSTypeCastExpression";
expression: Expression;
typeAnnotation: TsTypeAnnotation;
};
export declare type FlowType = Node;
export declare type FlowPredicate = Node;
export declare type FlowDeclare = Node;
export declare type FlowDeclareClass = Node;
export declare type FlowDeclareExportDeclaration = Node;
export declare type FlowDeclareFunction = Node;
export declare type FlowDeclareVariable = Node;
export declare type FlowDeclareModule = Node;
export declare type FlowDeclareModuleExports = Node;
export declare type FlowDeclareTypeAlias = Node;
export declare type FlowDeclareOpaqueType = Node;
export declare type FlowDeclareInterface = Node;
export declare type FlowInterface = Node;
export declare type FlowInterfaceExtends = Node;
export declare type FlowTypeAlias = Node;
export declare type FlowOpaqueType = Node;
export declare type FlowObjectTypeIndexer = Node;
export declare type FlowFunctionTypeAnnotation = Node;
export declare type FlowObjectTypeProperty = Node;
export declare type FlowObjectTypeSpreadProperty = Node;
export declare type FlowObjectTypeCallProperty = Node;
export declare type FlowObjectTypeAnnotation = Node;
export declare type FlowQualifiedTypeIdentifier = Node;
export declare type FlowGenericTypeAnnotation = Node;
export declare type FlowTypeofTypeAnnotation = Node;
export declare type FlowTupleTypeAnnotation = Node;
export declare type FlowFunctionTypeParam = Node;
export declare type FlowTypeAnnotation = Node;
export declare type FlowVariance = Node;
export declare type FlowClassImplements = Node;
export declare type TSParameterProperty = HasDecorators & {
type: "TSParameterProperty";
accessibility?: Accessibility | null;
readonly?: true | null;
parameter: Identifier | AssignmentPattern;
};
export declare type OptTSDeclareFunction = BodilessFunctionBase & DeclarationBase & {
type: "TSDeclareFunction";
};
export declare type TSDeclareFunction = OptTSDeclareFunction & {
id: Identifier;
};
export declare type TSDeclareMethod = BodilessFunctionOrMethodBase & ClassMethodOrDeclareMethodCommon & {
type: "TSDeclareMethod";
kind: MethodKind;
};
export declare type TsQualifiedName = NodeBase & {
type: "TSQualifiedName";
left: TsEntityName;
right: Identifier;
};
export declare type TsEntityName = Identifier | TsQualifiedName;
export declare type TsSignatureDeclaration = TsCallSignatureDeclaration | TsConstructSignatureDeclaration | TsMethodSignature | TsFunctionType | TsConstructorType;
export declare type TsSignatureDeclarationOrIndexSignatureBase = NodeBase & {
parameters: ReadonlyArray<Identifier | RestElement>;
typeAnnotation: TsTypeAnnotation | null;
};
export declare type TsSignatureDeclarationBase = TsSignatureDeclarationOrIndexSignatureBase & {
typeParameters: TsTypeParameterDeclaration | null;
};
export declare type TsTypeElement = TsCallSignatureDeclaration | TsConstructSignatureDeclaration | TsPropertySignature | TsMethodSignature | TsIndexSignature;
export declare type TsCallSignatureDeclaration = TsSignatureDeclarationBase & {
type: "TSCallSignatureDeclaration";
};
export declare type TsConstructSignatureDeclaration = TsSignatureDeclarationBase & {
type: "TSConstructSignature";
};
export declare type TsNamedTypeElementBase = NodeBase & {
key: Expression;
computed: boolean;
optional?: true;
};
export declare type TsPropertySignature = TsNamedTypeElementBase & {
type: "TSPropertySignature";
readonly?: true;
typeAnnotation?: TsTypeAnnotation;
initializer?: Expression;
};
export declare type TsMethodSignature = TsSignatureDeclarationBase & TsNamedTypeElementBase & {
type: "TSMethodSignature";
};
export declare type TsIndexSignature = TsSignatureDeclarationOrIndexSignatureBase & {
readonly?: true;
type: "TSIndexSignature";
};
export declare type TsType = TsKeywordType | TsThisType | TsFunctionOrConstructorType | TsTypeReference | TsTypeQuery | TsTypeLiteral | TsArrayType | TsTupleType | TsUnionOrIntersectionType | TsParenthesizedType | TsTypeOperator | TsIndexedAccessType | TsMappedType | TsLiteralType | TsTypePredicate;
export declare type TsTypeBase = NodeBase;
export declare type TsKeywordTypeType = "TSAnyKeyword" | "TSNumberKeyword" | "TSObjectKeyword" | "TSBooleanKeyword" | "TSStringKeyword" | "TSSymbolKeyword" | "TSVoidKeyword" | "TSUndefinedKeyword" | "TSNullKeyword" | "TSNeverKeyword";
export declare type TsKeywordType = TsTypeBase & {
type: TsKeywordTypeType;
};
export declare type TsThisType = TsTypeBase & {
type: "TSThisType";
};
export declare type TsFunctionOrConstructorType = TsFunctionType | TsConstructorType;
export declare type TsFunctionType = TsTypeBase & TsSignatureDeclarationBase & {
type: "TSFunctionType";
typeAnnotation: TypeAnnotation;
};
export declare type TsConstructorType = TsTypeBase & TsSignatureDeclarationBase & {
type: "TSConstructorType";
typeAnnotation: TsTypeAnnotation;
};
export declare type TsTypeReference = TsTypeBase & {
type: "TSTypeReference";
typeName: TsEntityName;
typeParameters?: TsTypeParameterInstantiation;
};
export declare type TsTypePredicate = TsTypeBase & {
type: "TSTypePredicate";
parameterName: Identifier | TsThisType;
typeAnnotation: TsTypeAnnotation;
};
export declare type TsTypeQuery = TsTypeBase & {
type: "TSTypeQuery";
exprName: TsEntityName;
};
export declare type TsTypeLiteral = TsTypeBase & {
type: "TSTypeLiteral";
members: ReadonlyArray<TsTypeElement>;
};
export declare type TsArrayType = TsTypeBase & {
type: "TSArrayType";
elementType: TsType;
};
export declare type TsTupleType = TsTypeBase & {
type: "TSTupleType";
elementTypes: ReadonlyArray<TsType>;
};
export declare type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
export declare type TsUnionOrIntersectionTypeBase = TsTypeBase & {
types: ReadonlyArray<TsType>;
};
export declare type TsUnionType = TsUnionOrIntersectionTypeBase & {
type: "TSUnionType";
};
export declare type TsIntersectionType = TsUnionOrIntersectionTypeBase & {
type: "TSIntersectionType";
};
export declare type TsParenthesizedType = TsTypeBase & {
type: "TSParenthesizedType";
typeAnnotation: TsType;
};
export declare type TsTypeOperator = TsTypeBase & {
type: "TSTypeOperator";
operator: "keyof";
typeAnnotation: TsType;
};
export declare type TsIndexedAccessType = TsTypeBase & {
type: "TSIndexedAccessType";
objectType: TsType;
indexType: TsType;
};
export declare type TsMappedType = TsTypeBase & {
type: "TSMappedType";
readonly?: true;
typeParameter: TsTypeParameter;
optional?: true;
typeAnnotation: TsType | null;
};
export declare type TsLiteralType = TsTypeBase & {
type: "TSLiteralType";
literal: NumericLiteral | StringLiteral | BooleanLiteral;
};
export declare type TsInterfaceDeclaration = DeclarationBase & {
type: "TSInterfaceDeclaration";
id: Identifier;
typeParameters: TsTypeParameterDeclaration | null;
extends?: ReadonlyArray<TsExpressionWithTypeArguments>;
body: TSInterfaceBody;
};
export declare type TSInterfaceBody = NodeBase & {
type: "TSInterfaceBody";
body: ReadonlyArray<TsTypeElement>;
};
export declare type TsExpressionWithTypeArguments = TsTypeBase & {
type: "TSExpressionWithTypeArguments";
expression: TsEntityName;
typeParameters?: TsTypeParameterInstantiation;
};
export declare type TsTypeAliasDeclaration = DeclarationBase & {
type: "TSTypeAliasDeclaration";
id: Identifier;
typeParameters: TsTypeParameterDeclaration | null;
typeAnnotation: TsType;
};
export declare type TsEnumDeclaration = DeclarationBase & {
type: "TSEnumDeclaration";
const?: true;
id: Identifier;
members: ReadonlyArray<TsEnumMember>;
};
export declare type TsEnumMember = NodeBase & {
type: "TSEnumMemodulmber";
id: Identifier | StringLiteral;
initializer?: Expression;
};
export declare type TsModuleDeclaration = DeclarationBase & {
type: "TSModuleDeclaration";
global?: true;
id: TsModuleName;
body: TsNamespaceBody;
};
export declare type TsNamespaceBody = TsModuleBlock | TsNamespaceDeclaration;
export declare type TsModuleBlock = NodeBase & {
type: "TSModuleBlock";
body: ReadonlyArray<Statement>;
};
export declare type TsNamespaceDeclaration = TsModuleDeclaration & {
id: Identifier;
body: TsNamespaceBody;
};
export declare type TsModuleName = Identifier | StringLiteral;
export declare type TsImportEqualsDeclaration = NodeBase & {
type: "TSImportEqualsDeclaration";
isExport: boolean;
id: Identifier;
moduleReference: TsModuleReference;
};
export declare type TsModuleReference = TsEntityName | TsExternalModuleReference;
export declare type TsExternalModuleReference = NodeBase & {
type: "TSExternalModuleReference";
expression: StringLiteral;
};
export declare type TsExportAssignment = NodeBase & {
type: "TSExportAssignment";
expression: Expression;
};
export declare type TsNamespaceExportDeclaration = NodeBase & {
type: "TSNamespaceExportDeclaration";
id: Identifier;
};
export declare type TsTypeAssertionLikeBase = NodeBase & {
expression: Expression;
typeAnnotation: TsType;
};
export declare type TsAsExpression = TsTypeAssertionLikeBase & {
type: "TSAsExpression";
};
export declare type TsTypeAssertion = TsTypeAssertionLikeBase & {
type: "TSTypeAssertion";
typeAnnotation: TsType;
expression: Expression;
};
export declare type TsNonNullExpression = NodeBase & {
type: "TSNonNullExpression";
expression: Expression;
};