[6a3a178] | 1 | // Type definitions for ESTree AST specification
|
---|
| 2 | // Project: https://github.com/estree/estree
|
---|
| 3 | // Definitions by: RReverser <https://github.com/RReverser>
|
---|
| 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
---|
| 5 |
|
---|
| 6 | // This definition file follows a somewhat unusual format. ESTree allows
|
---|
| 7 | // runtime type checks based on the `type` parameter. In order to explain this
|
---|
| 8 | // to typescript we want to use discriminated union types:
|
---|
| 9 | // https://github.com/Microsoft/TypeScript/pull/9163
|
---|
| 10 | //
|
---|
| 11 | // For ESTree this is a bit tricky because the high level interfaces like
|
---|
| 12 | // Node or Function are pulling double duty. We want to pass common fields down
|
---|
| 13 | // to the interfaces that extend them (like Identifier or
|
---|
| 14 | // ArrowFunctionExpression), but you can't extend a type union or enforce
|
---|
| 15 | // common fields on them. So we've split the high level interfaces into two
|
---|
| 16 | // types, a base type which passes down inherited fields, and a type union of
|
---|
| 17 | // all types which extend the base type. Only the type union is exported, and
|
---|
| 18 | // the union is how other types refer to the collection of inheriting types.
|
---|
| 19 | //
|
---|
| 20 | // This makes the definitions file here somewhat more difficult to maintain,
|
---|
| 21 | // but it has the notable advantage of making ESTree much easier to use as
|
---|
| 22 | // an end user.
|
---|
| 23 |
|
---|
| 24 | interface BaseNodeWithoutComments {
|
---|
| 25 | // Every leaf interface that extends BaseNode must specify a type property.
|
---|
| 26 | // The type property should be a string literal. For example, Identifier
|
---|
| 27 | // has: `type: "Identifier"`
|
---|
| 28 | type: string;
|
---|
| 29 | loc?: SourceLocation | null | undefined;
|
---|
| 30 | range?: [number, number] | undefined;
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | interface BaseNode extends BaseNodeWithoutComments {
|
---|
| 34 | leadingComments?: Array<Comment> | undefined;
|
---|
| 35 | trailingComments?: Array<Comment> | undefined;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | export type Node =
|
---|
| 39 | Identifier | Literal | Program | Function | SwitchCase | CatchClause |
|
---|
| 40 | VariableDeclarator | Statement | Expression | PrivateIdentifier | Property | PropertyDefinition |
|
---|
| 41 | AssignmentProperty | Super | TemplateElement | SpreadElement | Pattern |
|
---|
| 42 | ClassBody | Class | MethodDefinition | ModuleDeclaration | ModuleSpecifier;
|
---|
| 43 |
|
---|
| 44 | export interface Comment extends BaseNodeWithoutComments {
|
---|
| 45 | type: "Line" | "Block";
|
---|
| 46 | value: string;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | interface SourceLocation {
|
---|
| 50 | source?: string | null | undefined;
|
---|
| 51 | start: Position;
|
---|
| 52 | end: Position;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | export interface Position {
|
---|
| 56 | /** >= 1 */
|
---|
| 57 | line: number;
|
---|
| 58 | /** >= 0 */
|
---|
| 59 | column: number;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | export interface Program extends BaseNode {
|
---|
| 63 | type: "Program";
|
---|
| 64 | sourceType: "script" | "module";
|
---|
| 65 | body: Array<Directive | Statement | ModuleDeclaration>;
|
---|
| 66 | comments?: Array<Comment> | undefined;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | export interface Directive extends BaseNode {
|
---|
| 70 | type: "ExpressionStatement";
|
---|
| 71 | expression: Literal;
|
---|
| 72 | directive: string;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | interface BaseFunction extends BaseNode {
|
---|
| 76 | params: Array<Pattern>;
|
---|
| 77 | generator?: boolean | undefined;
|
---|
| 78 | async?: boolean | undefined;
|
---|
| 79 | // The body is either BlockStatement or Expression because arrow functions
|
---|
| 80 | // can have a body that's either. FunctionDeclarations and
|
---|
| 81 | // FunctionExpressions have only BlockStatement bodies.
|
---|
| 82 | body: BlockStatement | Expression;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | export type Function =
|
---|
| 86 | FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
---|
| 87 |
|
---|
| 88 | export type Statement =
|
---|
| 89 | ExpressionStatement | BlockStatement | EmptyStatement |
|
---|
| 90 | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement |
|
---|
| 91 | BreakStatement | ContinueStatement | IfStatement | SwitchStatement |
|
---|
| 92 | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement |
|
---|
| 93 | ForStatement | ForInStatement | ForOfStatement | Declaration;
|
---|
| 94 |
|
---|
| 95 | interface BaseStatement extends BaseNode { }
|
---|
| 96 |
|
---|
| 97 | export interface EmptyStatement extends BaseStatement {
|
---|
| 98 | type: "EmptyStatement";
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | export interface BlockStatement extends BaseStatement {
|
---|
| 102 | type: "BlockStatement";
|
---|
| 103 | body: Array<Statement>;
|
---|
| 104 | innerComments?: Array<Comment> | undefined;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | export interface ExpressionStatement extends BaseStatement {
|
---|
| 108 | type: "ExpressionStatement";
|
---|
| 109 | expression: Expression;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | export interface IfStatement extends BaseStatement {
|
---|
| 113 | type: "IfStatement";
|
---|
| 114 | test: Expression;
|
---|
| 115 | consequent: Statement;
|
---|
| 116 | alternate?: Statement | null | undefined;
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | export interface LabeledStatement extends BaseStatement {
|
---|
| 120 | type: "LabeledStatement";
|
---|
| 121 | label: Identifier;
|
---|
| 122 | body: Statement;
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | export interface BreakStatement extends BaseStatement {
|
---|
| 126 | type: "BreakStatement";
|
---|
| 127 | label?: Identifier | null | undefined;
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | export interface ContinueStatement extends BaseStatement {
|
---|
| 131 | type: "ContinueStatement";
|
---|
| 132 | label?: Identifier | null | undefined;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | export interface WithStatement extends BaseStatement {
|
---|
| 136 | type: "WithStatement";
|
---|
| 137 | object: Expression;
|
---|
| 138 | body: Statement;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | export interface SwitchStatement extends BaseStatement {
|
---|
| 142 | type: "SwitchStatement";
|
---|
| 143 | discriminant: Expression;
|
---|
| 144 | cases: Array<SwitchCase>;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | export interface ReturnStatement extends BaseStatement {
|
---|
| 148 | type: "ReturnStatement";
|
---|
| 149 | argument?: Expression | null | undefined;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | export interface ThrowStatement extends BaseStatement {
|
---|
| 153 | type: "ThrowStatement";
|
---|
| 154 | argument: Expression;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | export interface TryStatement extends BaseStatement {
|
---|
| 158 | type: "TryStatement";
|
---|
| 159 | block: BlockStatement;
|
---|
| 160 | handler?: CatchClause | null | undefined;
|
---|
| 161 | finalizer?: BlockStatement | null | undefined;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | export interface WhileStatement extends BaseStatement {
|
---|
| 165 | type: "WhileStatement";
|
---|
| 166 | test: Expression;
|
---|
| 167 | body: Statement;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | export interface DoWhileStatement extends BaseStatement {
|
---|
| 171 | type: "DoWhileStatement";
|
---|
| 172 | body: Statement;
|
---|
| 173 | test: Expression;
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | export interface ForStatement extends BaseStatement {
|
---|
| 177 | type: "ForStatement";
|
---|
| 178 | init?: VariableDeclaration | Expression | null | undefined;
|
---|
| 179 | test?: Expression | null | undefined;
|
---|
| 180 | update?: Expression | null | undefined;
|
---|
| 181 | body: Statement;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | interface BaseForXStatement extends BaseStatement {
|
---|
| 185 | left: VariableDeclaration | Pattern;
|
---|
| 186 | right: Expression;
|
---|
| 187 | body: Statement;
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | export interface ForInStatement extends BaseForXStatement {
|
---|
| 191 | type: "ForInStatement";
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | export interface DebuggerStatement extends BaseStatement {
|
---|
| 195 | type: "DebuggerStatement";
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | export type Declaration =
|
---|
| 199 | FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
---|
| 200 |
|
---|
| 201 | interface BaseDeclaration extends BaseStatement { }
|
---|
| 202 |
|
---|
| 203 | export interface FunctionDeclaration extends BaseFunction, BaseDeclaration {
|
---|
| 204 | type: "FunctionDeclaration";
|
---|
| 205 | /** It is null when a function declaration is a part of the `export default function` statement */
|
---|
| 206 | id: Identifier | null;
|
---|
| 207 | body: BlockStatement;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | export interface VariableDeclaration extends BaseDeclaration {
|
---|
| 211 | type: "VariableDeclaration";
|
---|
| 212 | declarations: Array<VariableDeclarator>;
|
---|
| 213 | kind: "var" | "let" | "const";
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | export interface VariableDeclarator extends BaseNode {
|
---|
| 217 | type: "VariableDeclarator";
|
---|
| 218 | id: Pattern;
|
---|
| 219 | init?: Expression | null | undefined;
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | type Expression =
|
---|
| 223 | ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression |
|
---|
| 224 | ArrowFunctionExpression | YieldExpression | Literal | UnaryExpression |
|
---|
| 225 | UpdateExpression | BinaryExpression | AssignmentExpression |
|
---|
| 226 | LogicalExpression | MemberExpression | ConditionalExpression |
|
---|
| 227 | CallExpression | NewExpression | SequenceExpression | TemplateLiteral |
|
---|
| 228 | TaggedTemplateExpression | ClassExpression | MetaProperty | Identifier |
|
---|
| 229 | AwaitExpression | ImportExpression | ChainExpression;
|
---|
| 230 |
|
---|
| 231 | export interface BaseExpression extends BaseNode { }
|
---|
| 232 |
|
---|
| 233 | type ChainElement = SimpleCallExpression | MemberExpression;
|
---|
| 234 |
|
---|
| 235 | export interface ChainExpression extends BaseExpression {
|
---|
| 236 | type: "ChainExpression";
|
---|
| 237 | expression: ChainElement;
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | export interface ThisExpression extends BaseExpression {
|
---|
| 241 | type: "ThisExpression";
|
---|
| 242 | }
|
---|
| 243 |
|
---|
| 244 | export interface ArrayExpression extends BaseExpression {
|
---|
| 245 | type: "ArrayExpression";
|
---|
| 246 | elements: Array<Expression | SpreadElement | null>;
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | export interface ObjectExpression extends BaseExpression {
|
---|
| 250 | type: "ObjectExpression";
|
---|
| 251 | properties: Array<Property | SpreadElement>;
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | export interface PrivateIdentifier extends BaseNode {
|
---|
| 255 | type: "PrivateIdentifier";
|
---|
| 256 | name: string;
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | export interface Property extends BaseNode {
|
---|
| 260 | type: "Property";
|
---|
| 261 | key: Expression | PrivateIdentifier;
|
---|
| 262 | value: Expression | Pattern; // Could be an AssignmentProperty
|
---|
| 263 | kind: "init" | "get" | "set";
|
---|
| 264 | method: boolean;
|
---|
| 265 | shorthand: boolean;
|
---|
| 266 | computed: boolean;
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 | export interface PropertyDefinition extends BaseNode {
|
---|
| 270 | type: "PropertyDefinition";
|
---|
| 271 | key: Expression | PrivateIdentifier;
|
---|
| 272 | value?: Expression | null | undefined;
|
---|
| 273 | computed: boolean;
|
---|
| 274 | static: boolean;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 | export interface FunctionExpression extends BaseFunction, BaseExpression {
|
---|
| 278 | id?: Identifier | null | undefined;
|
---|
| 279 | type: "FunctionExpression";
|
---|
| 280 | body: BlockStatement;
|
---|
| 281 | }
|
---|
| 282 |
|
---|
| 283 | export interface SequenceExpression extends BaseExpression {
|
---|
| 284 | type: "SequenceExpression";
|
---|
| 285 | expressions: Array<Expression>;
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 | export interface UnaryExpression extends BaseExpression {
|
---|
| 289 | type: "UnaryExpression";
|
---|
| 290 | operator: UnaryOperator;
|
---|
| 291 | prefix: true;
|
---|
| 292 | argument: Expression;
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | export interface BinaryExpression extends BaseExpression {
|
---|
| 296 | type: "BinaryExpression";
|
---|
| 297 | operator: BinaryOperator;
|
---|
| 298 | left: Expression;
|
---|
| 299 | right: Expression;
|
---|
| 300 | }
|
---|
| 301 |
|
---|
| 302 | export interface AssignmentExpression extends BaseExpression {
|
---|
| 303 | type: "AssignmentExpression";
|
---|
| 304 | operator: AssignmentOperator;
|
---|
| 305 | left: Pattern | MemberExpression;
|
---|
| 306 | right: Expression;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
| 309 | export interface UpdateExpression extends BaseExpression {
|
---|
| 310 | type: "UpdateExpression";
|
---|
| 311 | operator: UpdateOperator;
|
---|
| 312 | argument: Expression;
|
---|
| 313 | prefix: boolean;
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | export interface LogicalExpression extends BaseExpression {
|
---|
| 317 | type: "LogicalExpression";
|
---|
| 318 | operator: LogicalOperator;
|
---|
| 319 | left: Expression;
|
---|
| 320 | right: Expression;
|
---|
| 321 | }
|
---|
| 322 |
|
---|
| 323 | export interface ConditionalExpression extends BaseExpression {
|
---|
| 324 | type: "ConditionalExpression";
|
---|
| 325 | test: Expression;
|
---|
| 326 | alternate: Expression;
|
---|
| 327 | consequent: Expression;
|
---|
| 328 | }
|
---|
| 329 |
|
---|
| 330 | interface BaseCallExpression extends BaseExpression {
|
---|
| 331 | callee: Expression | Super;
|
---|
| 332 | arguments: Array<Expression | SpreadElement>;
|
---|
| 333 | }
|
---|
| 334 | export type CallExpression = SimpleCallExpression | NewExpression;
|
---|
| 335 |
|
---|
| 336 | export interface SimpleCallExpression extends BaseCallExpression {
|
---|
| 337 | type: "CallExpression";
|
---|
| 338 | optional: boolean;
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 | export interface NewExpression extends BaseCallExpression {
|
---|
| 342 | type: "NewExpression";
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | export interface MemberExpression extends BaseExpression, BasePattern {
|
---|
| 346 | type: "MemberExpression";
|
---|
| 347 | object: Expression | Super;
|
---|
| 348 | property: Expression | PrivateIdentifier;
|
---|
| 349 | computed: boolean;
|
---|
| 350 | optional: boolean;
|
---|
| 351 | }
|
---|
| 352 |
|
---|
| 353 | export type Pattern =
|
---|
| 354 | Identifier | ObjectPattern | ArrayPattern | RestElement |
|
---|
| 355 | AssignmentPattern | MemberExpression;
|
---|
| 356 |
|
---|
| 357 | interface BasePattern extends BaseNode { }
|
---|
| 358 |
|
---|
| 359 | export interface SwitchCase extends BaseNode {
|
---|
| 360 | type: "SwitchCase";
|
---|
| 361 | test?: Expression | null | undefined;
|
---|
| 362 | consequent: Array<Statement>;
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | export interface CatchClause extends BaseNode {
|
---|
| 366 | type: "CatchClause";
|
---|
| 367 | param: Pattern | null;
|
---|
| 368 | body: BlockStatement;
|
---|
| 369 | }
|
---|
| 370 |
|
---|
| 371 | export interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
---|
| 372 | type: "Identifier";
|
---|
| 373 | name: string;
|
---|
| 374 | }
|
---|
| 375 |
|
---|
| 376 | export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
---|
| 377 |
|
---|
| 378 | export interface SimpleLiteral extends BaseNode, BaseExpression {
|
---|
| 379 | type: "Literal";
|
---|
| 380 | value: string | boolean | number | null;
|
---|
| 381 | raw?: string | undefined;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
| 384 | export interface RegExpLiteral extends BaseNode, BaseExpression {
|
---|
| 385 | type: "Literal";
|
---|
| 386 | value?: RegExp | null | undefined;
|
---|
| 387 | regex: {
|
---|
| 388 | pattern: string;
|
---|
| 389 | flags: string;
|
---|
| 390 | };
|
---|
| 391 | raw?: string | undefined;
|
---|
| 392 | }
|
---|
| 393 |
|
---|
| 394 | export interface BigIntLiteral extends BaseNode, BaseExpression {
|
---|
| 395 | type: "Literal";
|
---|
| 396 | value?: bigint | null | undefined;
|
---|
| 397 | bigint: string;
|
---|
| 398 | raw?: string | undefined;
|
---|
| 399 | }
|
---|
| 400 |
|
---|
| 401 | export type UnaryOperator =
|
---|
| 402 | "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
---|
| 403 |
|
---|
| 404 | export type BinaryOperator =
|
---|
| 405 | "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" |
|
---|
| 406 | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "**" | "|" | "^" | "&" | "in" |
|
---|
| 407 | "instanceof";
|
---|
| 408 |
|
---|
| 409 | export type LogicalOperator = "||" | "&&" | "??";
|
---|
| 410 |
|
---|
| 411 | export type AssignmentOperator =
|
---|
| 412 | "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "**=" | "<<=" | ">>=" | ">>>=" |
|
---|
| 413 | "|=" | "^=" | "&=";
|
---|
| 414 |
|
---|
| 415 | export type UpdateOperator = "++" | "--";
|
---|
| 416 |
|
---|
| 417 | export interface ForOfStatement extends BaseForXStatement {
|
---|
| 418 | type: "ForOfStatement";
|
---|
| 419 | await: boolean;
|
---|
| 420 | }
|
---|
| 421 |
|
---|
| 422 | export interface Super extends BaseNode {
|
---|
| 423 | type: "Super";
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 | export interface SpreadElement extends BaseNode {
|
---|
| 427 | type: "SpreadElement";
|
---|
| 428 | argument: Expression;
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
---|
| 432 | type: "ArrowFunctionExpression";
|
---|
| 433 | expression: boolean;
|
---|
| 434 | body: BlockStatement | Expression;
|
---|
| 435 | }
|
---|
| 436 |
|
---|
| 437 | export interface YieldExpression extends BaseExpression {
|
---|
| 438 | type: "YieldExpression";
|
---|
| 439 | argument?: Expression | null | undefined;
|
---|
| 440 | delegate: boolean;
|
---|
| 441 | }
|
---|
| 442 |
|
---|
| 443 | export interface TemplateLiteral extends BaseExpression {
|
---|
| 444 | type: "TemplateLiteral";
|
---|
| 445 | quasis: Array<TemplateElement>;
|
---|
| 446 | expressions: Array<Expression>;
|
---|
| 447 | }
|
---|
| 448 |
|
---|
| 449 | export interface TaggedTemplateExpression extends BaseExpression {
|
---|
| 450 | type: "TaggedTemplateExpression";
|
---|
| 451 | tag: Expression;
|
---|
| 452 | quasi: TemplateLiteral;
|
---|
| 453 | }
|
---|
| 454 |
|
---|
| 455 | export interface TemplateElement extends BaseNode {
|
---|
| 456 | type: "TemplateElement";
|
---|
| 457 | tail: boolean;
|
---|
| 458 | value: {
|
---|
| 459 | /** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
|
---|
| 460 | cooked?: string | null | undefined;
|
---|
| 461 | raw: string;
|
---|
| 462 | };
|
---|
| 463 | }
|
---|
| 464 |
|
---|
| 465 | export interface AssignmentProperty extends Property {
|
---|
| 466 | value: Pattern;
|
---|
| 467 | kind: "init";
|
---|
| 468 | method: boolean; // false
|
---|
| 469 | }
|
---|
| 470 |
|
---|
| 471 | export interface ObjectPattern extends BasePattern {
|
---|
| 472 | type: "ObjectPattern";
|
---|
| 473 | properties: Array<AssignmentProperty | RestElement>;
|
---|
| 474 | }
|
---|
| 475 |
|
---|
| 476 | export interface ArrayPattern extends BasePattern {
|
---|
| 477 | type: "ArrayPattern";
|
---|
| 478 | elements: Array<Pattern | null>;
|
---|
| 479 | }
|
---|
| 480 |
|
---|
| 481 | export interface RestElement extends BasePattern {
|
---|
| 482 | type: "RestElement";
|
---|
| 483 | argument: Pattern;
|
---|
| 484 | }
|
---|
| 485 |
|
---|
| 486 | export interface AssignmentPattern extends BasePattern {
|
---|
| 487 | type: "AssignmentPattern";
|
---|
| 488 | left: Pattern;
|
---|
| 489 | right: Expression;
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | export type Class = ClassDeclaration | ClassExpression;
|
---|
| 493 | interface BaseClass extends BaseNode {
|
---|
| 494 | superClass?: Expression | null | undefined;
|
---|
| 495 | body: ClassBody;
|
---|
| 496 | }
|
---|
| 497 |
|
---|
| 498 | export interface ClassBody extends BaseNode {
|
---|
| 499 | type: "ClassBody";
|
---|
| 500 | body: Array<MethodDefinition | PropertyDefinition>;
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 | export interface MethodDefinition extends BaseNode {
|
---|
| 504 | type: "MethodDefinition";
|
---|
| 505 | key: Expression | PrivateIdentifier;
|
---|
| 506 | value: FunctionExpression;
|
---|
| 507 | kind: "constructor" | "method" | "get" | "set";
|
---|
| 508 | computed: boolean;
|
---|
| 509 | static: boolean;
|
---|
| 510 | }
|
---|
| 511 |
|
---|
| 512 | export interface ClassDeclaration extends BaseClass, BaseDeclaration {
|
---|
| 513 | type: "ClassDeclaration";
|
---|
| 514 | /** It is null when a class declaration is a part of the `export default class` statement */
|
---|
| 515 | id: Identifier | null;
|
---|
| 516 | }
|
---|
| 517 |
|
---|
| 518 | export interface ClassExpression extends BaseClass, BaseExpression {
|
---|
| 519 | type: "ClassExpression";
|
---|
| 520 | id?: Identifier | null | undefined;
|
---|
| 521 | }
|
---|
| 522 |
|
---|
| 523 | export interface MetaProperty extends BaseExpression {
|
---|
| 524 | type: "MetaProperty";
|
---|
| 525 | meta: Identifier;
|
---|
| 526 | property: Identifier;
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 | export type ModuleDeclaration =
|
---|
| 530 | ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration |
|
---|
| 531 | ExportAllDeclaration;
|
---|
| 532 | interface BaseModuleDeclaration extends BaseNode { }
|
---|
| 533 |
|
---|
| 534 | export type ModuleSpecifier =
|
---|
| 535 | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier |
|
---|
| 536 | ExportSpecifier;
|
---|
| 537 | interface BaseModuleSpecifier extends BaseNode {
|
---|
| 538 | local: Identifier;
|
---|
| 539 | }
|
---|
| 540 |
|
---|
| 541 | export interface ImportDeclaration extends BaseModuleDeclaration {
|
---|
| 542 | type: "ImportDeclaration";
|
---|
| 543 | specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
---|
| 544 | source: Literal;
|
---|
| 545 | }
|
---|
| 546 |
|
---|
| 547 | export interface ImportSpecifier extends BaseModuleSpecifier {
|
---|
| 548 | type: "ImportSpecifier";
|
---|
| 549 | imported: Identifier;
|
---|
| 550 | }
|
---|
| 551 |
|
---|
| 552 | export interface ImportExpression extends BaseExpression {
|
---|
| 553 | type: "ImportExpression";
|
---|
| 554 | source: Expression;
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
---|
| 558 | type: "ImportDefaultSpecifier";
|
---|
| 559 | }
|
---|
| 560 |
|
---|
| 561 | export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
---|
| 562 | type: "ImportNamespaceSpecifier";
|
---|
| 563 | }
|
---|
| 564 |
|
---|
| 565 | export interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
---|
| 566 | type: "ExportNamedDeclaration";
|
---|
| 567 | declaration?: Declaration | null | undefined;
|
---|
| 568 | specifiers: Array<ExportSpecifier>;
|
---|
| 569 | source?: Literal | null | undefined;
|
---|
| 570 | }
|
---|
| 571 |
|
---|
| 572 | export interface ExportSpecifier extends BaseModuleSpecifier {
|
---|
| 573 | type: "ExportSpecifier";
|
---|
| 574 | exported: Identifier;
|
---|
| 575 | }
|
---|
| 576 |
|
---|
| 577 | export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
---|
| 578 | type: "ExportDefaultDeclaration";
|
---|
| 579 | declaration: Declaration | Expression;
|
---|
| 580 | }
|
---|
| 581 |
|
---|
| 582 | export interface ExportAllDeclaration extends BaseModuleDeclaration {
|
---|
| 583 | type: "ExportAllDeclaration";
|
---|
| 584 | exported: Identifier | null;
|
---|
| 585 | source: Literal;
|
---|
| 586 | }
|
---|
| 587 |
|
---|
| 588 | export interface AwaitExpression extends BaseExpression {
|
---|
| 589 | type: "AwaitExpression";
|
---|
| 590 | argument: Expression;
|
---|
| 591 | }
|
---|