@typescript-eslint/types 8.0.0-alpha.8 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -163,9 +163,6 @@ export declare enum AST_NODE_TYPES {
163
163
  WhileStatement = "WhileStatement",
164
164
  WithStatement = "WithStatement",
165
165
  YieldExpression = "YieldExpression",
166
- /**
167
- * TS-prefixed nodes
168
- */
169
166
  TSAbstractAccessorProperty = "TSAbstractAccessorProperty",
170
167
  TSAbstractKeyword = "TSAbstractKeyword",
171
168
  TSAbstractMethodDefinition = "TSAbstractMethodDefinition",
@@ -330,11 +327,9 @@ export declare interface BreakStatement extends BaseNode {
330
327
  }
331
328
  export declare interface CallExpression extends BaseNode {
332
329
  type: AST_NODE_TYPES.CallExpression;
333
- callee: LeftHandSideExpression;
330
+ callee: Expression;
334
331
  arguments: CallExpressionArgument[];
335
332
  typeArguments: TSTypeParameterInstantiation | undefined;
336
- /** @deprecated Use {@link `typeArguments`} instead. */
337
- typeParameters: TSTypeParameterInstantiation | undefined;
338
333
  optional: boolean;
339
334
  }
340
335
  export declare type CallExpressionArgument = Expression | SpreadElement;
@@ -351,8 +346,9 @@ export declare interface ChainExpression extends BaseNode {
351
346
  declare interface ClassBase extends BaseNode {
352
347
  /**
353
348
  * Whether the class is an abstract class.
354
- * ```
355
- * abstract class Foo {...}
349
+ * @example
350
+ * ```ts
351
+ * abstract class Foo {}
356
352
  * ```
357
353
  */
358
354
  abstract: boolean;
@@ -362,16 +358,18 @@ declare interface ClassBase extends BaseNode {
362
358
  body: ClassBody;
363
359
  /**
364
360
  * Whether the class has been `declare`d:
365
- * ```
366
- * declare class Foo {...}
361
+ * @example
362
+ * ```ts
363
+ * declare class Foo {}
367
364
  * ```
368
365
  */
369
366
  declare: boolean;
370
367
  /**
371
368
  * The decorators declared for the class.
372
- * ```
369
+ * @example
370
+ * ```ts
373
371
  * @deco
374
- * class Foo {...}
372
+ * class Foo {}
375
373
  * ```
376
374
  */
377
375
  decorators: Decorator[];
@@ -394,8 +392,6 @@ declare interface ClassBase extends BaseNode {
394
392
  * The generic type parameters passed to the superClass.
395
393
  */
396
394
  superTypeArguments: TSTypeParameterInstantiation | undefined;
397
- /** @deprecated Use {@link `superTypeArguments`} instead. */
398
- superTypeParameters: TSTypeParameterInstantiation | undefined;
399
395
  /**
400
396
  * The generic type parameters declared for the class.
401
397
  */
@@ -409,9 +405,21 @@ export declare type ClassDeclaration = ClassDeclarationWithName | ClassDeclarati
409
405
  declare interface ClassDeclarationBase extends ClassBase {
410
406
  type: AST_NODE_TYPES.ClassDeclaration;
411
407
  }
408
+ /**
409
+ * A normal class declaration:
410
+ * ```
411
+ * class A {}
412
+ * ```
413
+ */
412
414
  export declare interface ClassDeclarationWithName extends ClassDeclarationBase {
413
415
  id: Identifier;
414
416
  }
417
+ /**
418
+ * Default-exported class declarations have optional names:
419
+ * ```
420
+ * export default class {}
421
+ * ```
422
+ */
415
423
  export declare interface ClassDeclarationWithOptionalName extends ClassDeclarationBase {
416
424
  id: Identifier | null;
417
425
  }
@@ -420,7 +428,6 @@ export declare interface ClassExpression extends ClassBase {
420
428
  type: AST_NODE_TYPES.ClassExpression;
421
429
  abstract: false;
422
430
  declare: false;
423
- decorators: [];
424
431
  }
425
432
  declare interface ClassMethodDefinitionNonComputedNameBase extends MethodDefinitionBase {
426
433
  key: ClassPropertyNameNonComputed;
@@ -445,6 +452,10 @@ export declare interface ContinueStatement extends BaseNode {
445
452
  export declare interface DebuggerStatement extends BaseNode {
446
453
  type: AST_NODE_TYPES.DebuggerStatement;
447
454
  }
455
+ /**
456
+ * @deprecated
457
+ * Note that this is neither up to date nor fully correct.
458
+ */
448
459
  export declare type DeclarationStatement = ClassDeclaration | ClassExpression | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | FunctionDeclaration | TSDeclareFunction | TSEnumDeclaration | TSImportEqualsDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSNamespaceExportDeclaration | TSTypeAliasDeclaration;
449
460
  export declare interface Decorator extends BaseNode {
450
461
  type: AST_NODE_TYPES.Decorator;
@@ -465,21 +476,23 @@ export declare interface ExportAllDeclaration extends BaseNode {
465
476
  type: AST_NODE_TYPES.ExportAllDeclaration;
466
477
  /**
467
478
  * The assertions declared for the export.
479
+ * @example
480
+ * ```ts
481
+ * export * from 'mod' assert \{ type: 'json' \};
468
482
  * ```
469
- * export * from 'mod' assert { type: 'json' };
470
- * ```
471
- * @deprecated -- Replaced with {@link `attributes`}.
483
+ * @deprecated Replaced with {@link `attributes`}.
472
484
  */
473
485
  assertions: ImportAttribute[];
474
486
  /**
475
487
  * The attributes declared for the export.
476
- * ```
477
- * export * from 'mod' assert { type: 'json' };
488
+ * @example
489
+ * ```ts
490
+ * export * from 'mod' with \{ type: 'json' \};
478
491
  * ```
479
492
  */
480
493
  attributes: ImportAttribute[];
481
494
  /**
482
- * The name for the exported items. `null` if no name is assigned.
495
+ * The name for the exported items (`as X`). `null` if no name is assigned.
483
496
  */
484
497
  exported: Identifier | null;
485
498
  /**
@@ -500,9 +513,9 @@ export declare interface ExportDefaultDeclaration extends BaseNode {
500
513
  */
501
514
  declaration: DefaultExportDeclarations;
502
515
  /**
503
- * The kind of the export.
516
+ * The kind of the export. Always `value` for default exports.
504
517
  */
505
- exportKind: ExportKind;
518
+ exportKind: 'value';
506
519
  }
507
520
  declare type ExportKind = ExportAndImportKind;
508
521
  export declare type ExportNamedDeclaration = ExportNamedDeclarationWithoutSourceWithMultiple | ExportNamedDeclarationWithoutSourceWithSingle | ExportNamedDeclarationWithSource;
@@ -510,8 +523,9 @@ declare interface ExportNamedDeclarationBase extends BaseNode {
510
523
  type: AST_NODE_TYPES.ExportNamedDeclaration;
511
524
  /**
512
525
  * The assertions declared for the export.
513
- * ```
514
- * export { foo } from 'mod' assert { type: 'json' };
526
+ * @example
527
+ * ```ts
528
+ * export { foo } from 'mod' assert \{ type: 'json' \};
515
529
  * ```
516
530
  * This will be an empty array if `source` is `null`
517
531
  * @deprecated Replaced with {@link `attributes`}.
@@ -519,15 +533,17 @@ declare interface ExportNamedDeclarationBase extends BaseNode {
519
533
  assertions: ImportAttribute[];
520
534
  /**
521
535
  * The attributes declared for the export.
522
- * ```
523
- * export { foo } from 'mod' assert { type: 'json' };
536
+ * @example
537
+ * ```ts
538
+ * export { foo } from 'mod' with \{ type: 'json' \};
524
539
  * ```
525
540
  * This will be an empty array if `source` is `null`
526
541
  */
527
542
  attributes: ImportAttribute[];
528
543
  /**
529
544
  * The exported declaration.
530
- * ```
545
+ * @example
546
+ * ```ts
531
547
  * export const x = 1;
532
548
  * ```
533
549
  * This will be `null` if `source` is not `null`, or if there are `specifiers`
@@ -543,13 +559,21 @@ declare interface ExportNamedDeclarationBase extends BaseNode {
543
559
  source: StringLiteral | null;
544
560
  /**
545
561
  * The specifiers being exported.
546
- * ```
562
+ * @example
563
+ * ```ts
547
564
  * export { a, b };
548
565
  * ```
549
566
  * This will be an empty array if `declaration` is not `null`
550
567
  */
551
568
  specifiers: ExportSpecifier[];
552
569
  }
570
+ /**
571
+ * Exporting names from the current module.
572
+ * ```
573
+ * export {};
574
+ * export { a, b };
575
+ * ```
576
+ */
553
577
  export declare interface ExportNamedDeclarationWithoutSourceWithMultiple extends ExportNamedDeclarationBase {
554
578
  /**
555
579
  * This will always be an empty array.
@@ -562,8 +586,13 @@ export declare interface ExportNamedDeclarationWithoutSourceWithMultiple extends
562
586
  attributes: ImportAttribute[];
563
587
  declaration: null;
564
588
  source: null;
565
- specifiers: ExportSpecifier[];
566
589
  }
590
+ /**
591
+ * Exporting a single named declaration.
592
+ * ```
593
+ * export const x = 1;
594
+ * ```
595
+ */
567
596
  export declare interface ExportNamedDeclarationWithoutSourceWithSingle extends ExportNamedDeclarationBase {
568
597
  /**
569
598
  * This will always be an empty array.
@@ -576,21 +605,20 @@ export declare interface ExportNamedDeclarationWithoutSourceWithSingle extends E
576
605
  attributes: ImportAttribute[];
577
606
  declaration: NamedExportDeclarations;
578
607
  source: null;
579
- specifiers: ExportSpecifier[];
580
- }
581
- export declare interface ExportNamedDeclarationWithSource extends ExportNamedDeclarationBase {
582
- /**
583
- * This will always be an empty array.
584
- * @deprecated Replaced with {@link `attributes`}.
585
- */
586
- assertions: ImportAttribute[];
587
608
  /**
588
609
  * This will always be an empty array.
589
610
  */
590
- attributes: ImportAttribute[];
611
+ specifiers: ExportSpecifier[];
612
+ }
613
+ /**
614
+ * Export names from another module.
615
+ * ```
616
+ * export { a, b } from 'mod';
617
+ * ```
618
+ */
619
+ export declare interface ExportNamedDeclarationWithSource extends ExportNamedDeclarationBase {
591
620
  declaration: null;
592
621
  source: StringLiteral;
593
- specifiers: ExportSpecifier[];
594
622
  }
595
623
  export declare interface ExportSpecifier extends BaseNode {
596
624
  type: AST_NODE_TYPES.ExportSpecifier;
@@ -630,16 +658,16 @@ declare interface FunctionBase extends BaseNode {
630
658
  /**
631
659
  * Whether the function is async:
632
660
  * ```
633
- * async function foo(...) {...}
634
- * const x = async function (...) {...}
635
- * const x = async (...) => {...}
661
+ * async function foo() {}
662
+ * const x = async function () {}
663
+ * const x = async () => {}
636
664
  * ```
637
665
  */
638
666
  async: boolean;
639
667
  /**
640
668
  * The body of the function.
641
669
  * - For an `ArrowFunctionExpression` this may be an `Expression` or `BlockStatement`.
642
- * - For a `FunctionDeclaration` or `FunctionExpression` this is always a `BlockStatement.
670
+ * - For a `FunctionDeclaration` or `FunctionExpression` this is always a `BlockStatement`.
643
671
  * - For a `TSDeclareFunction` this is always `undefined`.
644
672
  * - For a `TSEmptyBodyFunctionExpression` this is always `null`.
645
673
  */
@@ -647,7 +675,7 @@ declare interface FunctionBase extends BaseNode {
647
675
  /**
648
676
  * This is only `true` if and only if the node is a `TSDeclareFunction` and it has `declare`:
649
677
  * ```
650
- * declare function foo(...) {...}
678
+ * declare function foo() {}
651
679
  * ```
652
680
  */
653
681
  declare: boolean;
@@ -662,8 +690,8 @@ declare interface FunctionBase extends BaseNode {
662
690
  /**
663
691
  * Whether the function is a generator function:
664
692
  * ```
665
- * function *foo(...) {...}
666
- * const x = function *(...) {...}
693
+ * function *foo() {}
694
+ * const x = function *() {}
667
695
  * ```
668
696
  * This is always `false` for arrow functions as they cannot be generators.
669
697
  */
@@ -696,9 +724,21 @@ declare interface FunctionDeclarationBase extends FunctionBase {
696
724
  declare: false;
697
725
  expression: false;
698
726
  }
727
+ /**
728
+ * A normal function declaration:
729
+ * ```
730
+ * function f() {}
731
+ * ```
732
+ */
699
733
  export declare interface FunctionDeclarationWithName extends FunctionDeclarationBase {
700
734
  id: Identifier;
701
735
  }
736
+ /**
737
+ * Default-exported function declarations have optional names:
738
+ * ```
739
+ * export default function () {}
740
+ * ```
741
+ */
702
742
  export declare interface FunctionDeclarationWithOptionalName extends FunctionDeclarationBase {
703
743
  id: Identifier | null;
704
744
  }
@@ -734,16 +774,18 @@ export declare interface ImportDeclaration extends BaseNode {
734
774
  type: AST_NODE_TYPES.ImportDeclaration;
735
775
  /**
736
776
  * The assertions declared for the export.
777
+ * @example
778
+ * ```ts
779
+ * import * from 'mod' assert \{ type: 'json' \};
737
780
  * ```
738
- * import * from 'mod' assert { type: 'json' };
739
- * ```
740
- * @deprecated -- Replaced with {@link `attributes`}.
781
+ * @deprecated Replaced with {@link `attributes`}.
741
782
  */
742
783
  assertions: ImportAttribute[];
743
784
  /**
744
785
  * The attributes declared for the export.
745
- * ```
746
- * import * from 'mod' with { type: 'json' };
786
+ * @example
787
+ * ```ts
788
+ * import * from 'mod' with \{ type: 'json' \};
747
789
  * ```
748
790
  */
749
791
  attributes: ImportAttribute[];
@@ -842,8 +884,6 @@ export declare interface JSXNamespacedName extends BaseNode {
842
884
  export declare interface JSXOpeningElement extends BaseNode {
843
885
  type: AST_NODE_TYPES.JSXOpeningElement;
844
886
  typeArguments: TSTypeParameterInstantiation | undefined;
845
- /** @deprecated Use {@link `typeArguments`} instead. */
846
- typeParameters: TSTypeParameterInstantiation | undefined;
847
887
  selfClosing: boolean;
848
888
  name: JSXTagNameExpression;
849
889
  attributes: (JSXAttribute | JSXSpreadAttribute)[];
@@ -882,7 +922,8 @@ export declare interface LetOrConstOrVarDeclaration extends BaseNode {
882
922
  /**
883
923
  * The variables declared by this declaration.
884
924
  * Note that there may be 0 declarations (i.e. `const;`).
885
- * ```
925
+ * @example
926
+ * ```ts
886
927
  * let x;
887
928
  * let y, z;
888
929
  * ```
@@ -890,14 +931,16 @@ export declare interface LetOrConstOrVarDeclaration extends BaseNode {
890
931
  declarations: LetOrConstOrVarDeclarator[];
891
932
  /**
892
933
  * Whether the declaration is `declare`d
893
- * ```
934
+ * @example
935
+ * ```ts
894
936
  * declare const x = 1;
895
937
  * ```
896
938
  */
897
939
  declare: boolean;
898
940
  /**
899
941
  * The keyword used to declare the variable(s)
900
- * ```
942
+ * @example
943
+ * ```ts
901
944
  * const x = 1;
902
945
  * let y = 2;
903
946
  * var z = 3;
@@ -979,11 +1022,9 @@ declare interface MethodDefinitionNonComputedNameBase extends MethodDefinitionBa
979
1022
  export declare type NamedExportDeclarations = ClassDeclarationWithName | ClassDeclarationWithOptionalName | FunctionDeclarationWithName | FunctionDeclarationWithOptionalName | TSDeclareFunction | TSEnumDeclaration | TSImportEqualsDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSTypeAliasDeclaration | VariableDeclaration;
980
1023
  export declare interface NewExpression extends BaseNode {
981
1024
  type: AST_NODE_TYPES.NewExpression;
982
- callee: LeftHandSideExpression;
1025
+ callee: Expression;
983
1026
  arguments: CallExpressionArgument[];
984
1027
  typeArguments: TSTypeParameterInstantiation | undefined;
985
- /** @deprecated Use {@link `typeArguments`} instead. */
986
- typeParameters: TSTypeParameterInstantiation | undefined;
987
1028
  }
988
1029
  export declare type Node = AccessorProperty | ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BinaryExpression | BlockStatement | BreakStatement | CallExpression | CatchClause | ChainExpression | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | ImportAttribute | ImportDeclaration | ImportDefaultSpecifier | ImportExpression | ImportNamespaceSpecifier | ImportSpecifier | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXMemberExpression | JSXNamespacedName | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXText | LabeledStatement | Literal | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | ObjectExpression | ObjectPattern | PrivateIdentifier | Program | Property | PropertyDefinition | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | TSAbstractAccessorProperty | TSAbstractKeyword | TSAbstractMethodDefinition | TSAbstractPropertyDefinition | TSAnyKeyword | TSArrayType | TSAsExpression | TSAsyncKeyword | TSBigIntKeyword | TSBooleanKeyword | TSCallSignatureDeclaration | TSClassImplements | TSConditionalType | TSConstructorType | TSConstructSignatureDeclaration | TSDeclareFunction | TSDeclareKeyword | TSEmptyBodyFunctionExpression | TSEnumBody | TSEnumDeclaration | TSEnumMember | TSExportAssignment | TSExportKeyword | TSExternalModuleReference | TSFunctionType | TSImportEqualsDeclaration | TSImportType | TSIndexedAccessType | TSIndexSignature | TSInferType | TSInstantiationExpression | TSInterfaceBody | TSInterfaceDeclaration | TSInterfaceHeritage | TSIntersectionType | TSIntrinsicKeyword | TSLiteralType | TSMappedType | TSMethodSignature | TSModuleBlock | TSModuleDeclaration | TSNamedTupleMember | TSNamespaceExportDeclaration | TSNeverKeyword | TSNonNullExpression | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSOptionalType | TSParameterProperty | TSPrivateKeyword | TSPropertySignature | TSProtectedKeyword | TSPublicKeyword | TSQualifiedName | TSReadonlyKeyword | TSRestType | TSSatisfiesExpression | TSStaticKeyword | TSStringKeyword | TSSymbolKeyword | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeAliasDeclaration | TSTypeAnnotation | TSTypeAssertion | TSTypeLiteral | TSTypeOperator | TSTypeParameter | TSTypeParameterDeclaration | TSTypeParameterInstantiation | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUndefinedKeyword | TSUnionType | TSUnknownKeyword | TSVoidKeyword | UnaryExpression | UpdateExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
989
1030
  export declare interface NodeOrTokenData {
@@ -991,13 +1032,8 @@ export declare interface NodeOrTokenData {
991
1032
  * The source location information of the node.
992
1033
  *
993
1034
  * The loc property is defined as nullable by ESTree, but ESLint requires this property.
994
- *
995
- * @see {SourceLocation}
996
1035
  */
997
1036
  loc: SourceLocation;
998
- /**
999
- * @see {Range}
1000
- */
1001
1037
  range: Range;
1002
1038
  type: string;
1003
1039
  }
@@ -1207,7 +1243,7 @@ export declare interface SpreadElement extends BaseNode {
1207
1243
  type: AST_NODE_TYPES.SpreadElement;
1208
1244
  argument: Expression;
1209
1245
  }
1210
- export declare type Statement = BlockStatement | BreakStatement | ClassDeclarationWithName | ContinueStatement | DebuggerStatement | DoWhileStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclarationWithName | IfStatement | ImportDeclaration | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | TSDeclareFunction | TSEnumDeclaration | TSExportAssignment | TSImportEqualsDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSNamespaceExportDeclaration | TSTypeAliasDeclaration | VariableDeclaration | WhileStatement | WithStatement;
1246
+ export declare type Statement = BlockStatement | BreakStatement | ClassDeclarationWithName | ContinueStatement | DebuggerStatement | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclarationWithName | IfStatement | ImportDeclaration | LabeledStatement | ReturnStatement | SwitchStatement | ThrowStatement | TryStatement | TSDeclareFunction | TSEnumDeclaration | TSExportAssignment | TSImportEqualsDeclaration | TSInterfaceDeclaration | TSModuleDeclaration | TSNamespaceExportDeclaration | TSTypeAliasDeclaration | VariableDeclaration | WhileStatement | WithStatement;
1211
1247
  export declare interface StaticBlock extends BaseNode {
1212
1248
  type: AST_NODE_TYPES.StaticBlock;
1213
1249
  body: Statement[];
@@ -1232,12 +1268,10 @@ export declare interface SwitchStatement extends BaseNode {
1232
1268
  cases: SwitchCase[];
1233
1269
  }
1234
1270
  export declare interface TaggedTemplateExpression extends BaseNode {
1271
+ quasi: TemplateLiteral;
1272
+ tag: Expression;
1235
1273
  type: AST_NODE_TYPES.TaggedTemplateExpression;
1236
1274
  typeArguments: TSTypeParameterInstantiation | undefined;
1237
- /** @deprecated Use {@link `typeArguments`} instead. */
1238
- typeParameters: TSTypeParameterInstantiation | undefined;
1239
- tag: LeftHandSideExpression;
1240
- quasi: TemplateLiteral;
1241
1275
  }
1242
1276
  export declare interface TemplateElement extends BaseNode {
1243
1277
  type: AST_NODE_TYPES.TemplateElement;
@@ -1338,12 +1372,52 @@ export declare interface TSConstructorType extends TSFunctionSignatureBase {
1338
1372
  export declare interface TSConstructSignatureDeclaration extends TSFunctionSignatureBase {
1339
1373
  type: AST_NODE_TYPES.TSConstructSignatureDeclaration;
1340
1374
  }
1341
- export declare interface TSDeclareFunction extends FunctionBase {
1375
+ export declare type TSDeclareFunction = TSDeclareFunctionNoDeclare | TSDeclareFunctionWithDeclare;
1376
+ declare interface TSDeclareFunctionBase extends FunctionBase {
1342
1377
  type: AST_NODE_TYPES.TSDeclareFunction;
1343
- body: BlockStatement | undefined;
1378
+ /**
1379
+ * TS1183: An implementation cannot be declared in ambient contexts.
1380
+ */
1381
+ body: undefined;
1382
+ /**
1383
+ * Whether the declaration has `declare` modifier.
1384
+ */
1344
1385
  declare: boolean;
1345
1386
  expression: false;
1346
1387
  }
1388
+ /**
1389
+ * Function declaration without the `declare` keyword:
1390
+ * ```
1391
+ * function foo(): void;
1392
+ * ```
1393
+ * This can either be an overload signature or a declaration in an ambient context
1394
+ * (e.g. `declare module`)
1395
+ */
1396
+ export declare interface TSDeclareFunctionNoDeclare extends TSDeclareFunctionBase {
1397
+ declare: false;
1398
+ /**
1399
+ * - TS1221: Generators are not allowed in an ambient context.
1400
+ * - TS1222: An overload signature cannot be declared as a generator.
1401
+ */
1402
+ generator: false;
1403
+ }
1404
+ /**
1405
+ * Function declaration with the `declare` keyword:
1406
+ * ```
1407
+ * declare function foo(): void;
1408
+ * ```
1409
+ */
1410
+ export declare interface TSDeclareFunctionWithDeclare extends TSDeclareFunctionBase {
1411
+ /**
1412
+ * TS1040: 'async' modifier cannot be used in an ambient context.
1413
+ */
1414
+ async: false;
1415
+ declare: true;
1416
+ /**
1417
+ * TS1221: Generators are not allowed in an ambient context.
1418
+ */
1419
+ generator: false;
1420
+ }
1347
1421
  export declare interface TSDeclareKeyword extends BaseNode {
1348
1422
  type: AST_NODE_TYPES.TSDeclareKeyword;
1349
1423
  }
@@ -1355,7 +1429,6 @@ export declare interface TSEmptyBodyFunctionExpression extends FunctionBase {
1355
1429
  export declare interface TSEnumBody extends BaseNode {
1356
1430
  type: AST_NODE_TYPES.TSEnumBody;
1357
1431
  members: TSEnumMember[];
1358
- parent: TSEnumDeclaration;
1359
1432
  }
1360
1433
  export declare interface TSEnumDeclaration extends BaseNode {
1361
1434
  type: AST_NODE_TYPES.TSEnumDeclaration;
@@ -1365,15 +1438,17 @@ export declare interface TSEnumDeclaration extends BaseNode {
1365
1438
  body: TSEnumBody;
1366
1439
  /**
1367
1440
  * Whether this is a `const` enum.
1368
- * ```
1369
- * const enum Foo {...}
1441
+ * @example
1442
+ * ```ts
1443
+ * const enum Foo {}
1370
1444
  * ```
1371
1445
  */
1372
1446
  const: boolean;
1373
1447
  /**
1374
1448
  * Whether this is a `declare`d enum.
1375
- * ```
1376
- * declare enum Foo {...}
1449
+ * @example
1450
+ * ```ts
1451
+ * declare enum Foo {}
1377
1452
  * ```
1378
1453
  */
1379
1454
  declare: boolean;
@@ -1393,18 +1468,20 @@ declare interface TSEnumMemberBase extends BaseNode {
1393
1468
  id: PropertyNameComputed | PropertyNameNonComputed;
1394
1469
  initializer: Expression | undefined;
1395
1470
  computed: boolean;
1396
- parent: TSEnumBody;
1397
1471
  }
1398
1472
  /**
1399
1473
  * this should only really happen in semantically invalid code (errors 1164 and 2452)
1400
1474
  *
1401
- * VALID:
1475
+ * @example
1476
+ * ```ts
1477
+ * // VALID:
1402
1478
  * enum Foo { ['a'] }
1403
1479
  *
1404
- * INVALID:
1480
+ * // INVALID:
1405
1481
  * const x = 'a';
1406
1482
  * enum Foo { [x] }
1407
1483
  * enum Bar { ['a' + 'b'] }
1484
+ * ```
1408
1485
  */
1409
1486
  export declare interface TSEnumMemberComputedName extends TSEnumMemberBase {
1410
1487
  id: PropertyNameComputed;
@@ -1423,7 +1500,7 @@ export declare interface TSExportKeyword extends BaseNode {
1423
1500
  }
1424
1501
  export declare interface TSExternalModuleReference extends BaseNode {
1425
1502
  type: AST_NODE_TYPES.TSExternalModuleReference;
1426
- expression: Expression;
1503
+ expression: StringLiteral;
1427
1504
  }
1428
1505
  declare interface TSFunctionSignatureBase extends BaseNode {
1429
1506
  params: Parameter[];
@@ -1436,24 +1513,55 @@ export declare interface TSFunctionType extends TSFunctionSignatureBase {
1436
1513
  declare interface TSHeritageBase extends BaseNode {
1437
1514
  expression: Expression;
1438
1515
  typeArguments: TSTypeParameterInstantiation | undefined;
1439
- /** @deprecated Use {@link `typeArguments`} instead. */
1440
- typeParameters: TSTypeParameterInstantiation | undefined;
1441
1516
  }
1442
- export declare interface TSImportEqualsDeclaration extends BaseNode {
1517
+ export declare type TSImportEqualsDeclaration = TSImportEqualsNamespaceDeclaration | TSImportEqualsRequireDeclaration;
1518
+ declare interface TSImportEqualsDeclarationBase extends BaseNode {
1443
1519
  type: AST_NODE_TYPES.TSImportEqualsDeclaration;
1444
1520
  /**
1445
- * The locally imported name
1521
+ * The locally imported name.
1446
1522
  */
1447
1523
  id: Identifier;
1524
+ /**
1525
+ * The value being aliased.
1526
+ * @example
1527
+ * ```ts
1528
+ * import F1 = A;
1529
+ * import F2 = A.B.C;
1530
+ * import F3 = require('mod');
1531
+ * ```
1532
+ */
1533
+ moduleReference: Identifier | TSExternalModuleReference | TSQualifiedName;
1534
+ /**
1535
+ * The kind of the import. Always `'value'` unless `moduleReference` is a
1536
+ * `TSExternalModuleReference`.
1537
+ */
1538
+ importKind: ImportKind;
1539
+ }
1540
+ export declare interface TSImportEqualsNamespaceDeclaration extends TSImportEqualsDeclarationBase {
1448
1541
  /**
1449
1542
  * The value being aliased.
1450
1543
  * ```
1451
1544
  * import F1 = A;
1452
1545
  * import F2 = A.B.C;
1546
+ * ```
1547
+ */
1548
+ moduleReference: Identifier | TSQualifiedName;
1549
+ /**
1550
+ * The kind of the import.
1551
+ */
1552
+ importKind: 'value';
1553
+ }
1554
+ export declare interface TSImportEqualsRequireDeclaration extends TSImportEqualsDeclarationBase {
1555
+ /**
1556
+ * The value being aliased.
1557
+ * ```
1453
1558
  * import F3 = require('mod');
1454
1559
  * ```
1455
1560
  */
1456
- moduleReference: EntityName | TSExternalModuleReference;
1561
+ moduleReference: TSExternalModuleReference;
1562
+ /**
1563
+ * The kind of the import.
1564
+ */
1457
1565
  importKind: ImportKind;
1458
1566
  }
1459
1567
  export declare interface TSImportType extends BaseNode {
@@ -1461,8 +1569,6 @@ export declare interface TSImportType extends BaseNode {
1461
1569
  argument: TypeNode;
1462
1570
  qualifier: EntityName | null;
1463
1571
  typeArguments: TSTypeParameterInstantiation | null;
1464
- /** @deprecated Use {@link `typeArguments`} instead. */
1465
- typeParameters: TSTypeParameterInstantiation | null;
1466
1572
  }
1467
1573
  export declare interface TSIndexedAccessType extends BaseNode {
1468
1574
  type: AST_NODE_TYPES.TSIndexedAccessType;
@@ -1485,8 +1591,6 @@ export declare interface TSInstantiationExpression extends BaseNode {
1485
1591
  type: AST_NODE_TYPES.TSInstantiationExpression;
1486
1592
  expression: Expression;
1487
1593
  typeArguments: TSTypeParameterInstantiation;
1488
- /** @deprecated Use {@link `typeArguments`} instead. */
1489
- typeParameters?: TSTypeParameterInstantiation;
1490
1594
  }
1491
1595
  export declare interface TSInterfaceBody extends BaseNode {
1492
1596
  type: AST_NODE_TYPES.TSInterfaceBody;
@@ -1499,7 +1603,7 @@ export declare interface TSInterfaceDeclaration extends BaseNode {
1499
1603
  */
1500
1604
  body: TSInterfaceBody;
1501
1605
  /**
1502
- * Whether the interface was `declare`d, `undefined` otherwise
1606
+ * Whether the interface was `declare`d
1503
1607
  */
1504
1608
  declare: boolean;
1505
1609
  /**
@@ -1511,7 +1615,8 @@ export declare interface TSInterfaceDeclaration extends BaseNode {
1511
1615
  */
1512
1616
  id: Identifier;
1513
1617
  /**
1514
- * The generic type parameters declared for the interface.
1618
+ * The generic type parameters declared for the interface. Empty declaration
1619
+ * (`<>`) is different from no declaration.
1515
1620
  */
1516
1621
  typeParameters: TSTypeParameterDeclaration | undefined;
1517
1622
  }
@@ -1581,60 +1686,86 @@ declare interface TSModuleDeclarationBase extends BaseNode {
1581
1686
  /**
1582
1687
  * The body of the module.
1583
1688
  * This can only be `undefined` for the code `declare module 'mod';`
1584
- * This will be a `TSModuleDeclaration` if the name is "nested" (`Foo.Bar`).
1585
1689
  */
1586
1690
  body?: TSModuleBlock;
1587
1691
  /**
1588
1692
  * Whether this is a global declaration
1589
- * ```
1693
+ * @example
1694
+ * ```ts
1590
1695
  * declare global {}
1591
1696
  * ```
1697
+ *
1698
+ * @deprecated Use {@link kind} instead
1592
1699
  */
1593
1700
  global: boolean;
1594
1701
  /**
1595
1702
  * Whether the module is `declare`d
1596
- * ```
1703
+ * @example
1704
+ * ```ts
1597
1705
  * declare namespace F {}
1598
1706
  * ```
1599
1707
  */
1600
1708
  declare: boolean;
1601
1709
  /**
1602
1710
  * The keyword used to define this module declaration
1603
- * ```
1711
+ * @example
1712
+ * ```ts
1604
1713
  * namespace Foo {}
1605
1714
  * ^^^^^^^^^
1606
1715
  *
1607
1716
  * module 'foo' {}
1608
1717
  * ^^^^^^
1609
1718
  *
1610
- * declare global {}
1611
- * ^^^^^^
1719
+ * global {}
1720
+ * ^^^^^^
1612
1721
  * ```
1613
1722
  */
1614
1723
  kind: TSModuleDeclarationKind;
1615
1724
  }
1616
1725
  export declare interface TSModuleDeclarationGlobal extends TSModuleDeclarationBase {
1617
1726
  kind: 'global';
1618
- body: TSModuleBlock;
1727
+ /**
1728
+ * This will always be an Identifier with name `global`
1729
+ */
1619
1730
  id: Identifier;
1731
+ body: TSModuleBlock;
1620
1732
  }
1621
1733
  export declare type TSModuleDeclarationKind = 'global' | 'module' | 'namespace';
1622
1734
  export declare type TSModuleDeclarationModule = TSModuleDeclarationModuleWithIdentifierId | TSModuleDeclarationModuleWithStringId;
1623
1735
  declare interface TSModuleDeclarationModuleBase extends TSModuleDeclarationBase {
1624
1736
  kind: 'module';
1625
1737
  }
1738
+ /**
1739
+ * The legacy module declaration, replaced with namespace declarations.
1740
+ * ```
1741
+ * module A {}
1742
+ * ```
1743
+ */
1626
1744
  export declare interface TSModuleDeclarationModuleWithIdentifierId extends TSModuleDeclarationModuleBase {
1627
1745
  kind: 'module';
1628
1746
  id: Identifier;
1629
1747
  body: TSModuleBlock;
1630
1748
  }
1631
1749
  export declare type TSModuleDeclarationModuleWithStringId = TSModuleDeclarationModuleWithStringIdDeclared | TSModuleDeclarationModuleWithStringIdNotDeclared;
1750
+ /**
1751
+ * A string module declaration that is declared:
1752
+ * ```
1753
+ * declare module 'foo' {}
1754
+ * declare module 'foo';
1755
+ * ```
1756
+ */
1632
1757
  export declare interface TSModuleDeclarationModuleWithStringIdDeclared extends TSModuleDeclarationModuleBase {
1633
1758
  kind: 'module';
1634
1759
  id: StringLiteral;
1635
1760
  declare: true;
1636
1761
  body?: TSModuleBlock;
1637
1762
  }
1763
+ /**
1764
+ * A string module declaration that is not declared:
1765
+ * ```
1766
+ * module 'foo' {}
1767
+ * ```
1768
+ */
1638
1769
  export declare interface TSModuleDeclarationModuleWithStringIdNotDeclared extends TSModuleDeclarationModuleBase {
1639
1770
  kind: 'module';
1640
1771
  id: StringLiteral;
@@ -1652,10 +1783,16 @@ export declare interface TSNamedTupleMember extends BaseNode {
1652
1783
  label: Identifier;
1653
1784
  optional: boolean;
1654
1785
  }
1786
+ /**
1787
+ * For the following declaration:
1788
+ * ```
1789
+ * export as namespace X;
1790
+ * ```
1791
+ */
1655
1792
  export declare interface TSNamespaceExportDeclaration extends BaseNode {
1656
1793
  type: AST_NODE_TYPES.TSNamespaceExportDeclaration;
1657
1794
  /**
1658
- * The name the global variable being exported to
1795
+ * The name of the global variable that's exported as namespace
1659
1796
  */
1660
1797
  id: Identifier;
1661
1798
  }
@@ -1758,7 +1895,8 @@ export declare interface TSTypeAliasDeclaration extends BaseNode {
1758
1895
  type: AST_NODE_TYPES.TSTypeAliasDeclaration;
1759
1896
  /**
1760
1897
  * Whether the type was `declare`d.
1761
- * ```
1898
+ * @example
1899
+ * ```ts
1762
1900
  * declare type T = 1;
1763
1901
  * ```
1764
1902
  */
@@ -1772,7 +1910,8 @@ export declare interface TSTypeAliasDeclaration extends BaseNode {
1772
1910
  */
1773
1911
  typeAnnotation: TypeNode;
1774
1912
  /**
1775
- * The generic type parameters declared for the type.
1913
+ * The generic type parameters declared for the type. Empty declaration
1914
+ * (`<>`) is different from no declaration.
1776
1915
  */
1777
1916
  typeParameters: TSTypeParameterDeclaration | undefined;
1778
1917
  }
@@ -1821,14 +1960,10 @@ export declare interface TSTypeQuery extends BaseNode {
1821
1960
  type: AST_NODE_TYPES.TSTypeQuery;
1822
1961
  exprName: EntityName | TSImportType;
1823
1962
  typeArguments: TSTypeParameterInstantiation | undefined;
1824
- /** @deprecated Use {@link `typeArguments`} instead. */
1825
- typeParameters: TSTypeParameterInstantiation | undefined;
1826
1963
  }
1827
1964
  export declare interface TSTypeReference extends BaseNode {
1828
1965
  type: AST_NODE_TYPES.TSTypeReference;
1829
1966
  typeArguments: TSTypeParameterInstantiation | undefined;
1830
- /** @deprecated Use {@link `typeArguments`} instead. */
1831
- typeParameters: TSTypeParameterInstantiation | undefined;
1832
1967
  typeName: EntityName;
1833
1968
  }
1834
1969
  export declare type TSUnaryExpression = AwaitExpression | LeftHandSideExpression | UnaryExpression | UpdateExpression;
@@ -1854,7 +1989,7 @@ export declare interface UnaryExpression extends UnaryExpressionBase {
1854
1989
  declare interface UnaryExpressionBase extends BaseNode {
1855
1990
  operator: string;
1856
1991
  prefix: boolean;
1857
- argument: LeftHandSideExpression | Literal | UnaryExpression;
1992
+ argument: Expression;
1858
1993
  }
1859
1994
  export declare interface UpdateExpression extends UnaryExpressionBase {
1860
1995
  type: AST_NODE_TYPES.UpdateExpression;
@@ -1867,7 +2002,8 @@ export declare interface UsingInForOfDeclaration extends BaseNode {
1867
2002
  /**
1868
2003
  * The variables declared by this declaration.
1869
2004
  * Note that there may be 0 declarations (i.e. `const;`).
1870
- * ```
2005
+ * @example
2006
+ * ```ts
1871
2007
  * for(using x of y){}
1872
2008
  * ```
1873
2009
  */
@@ -1879,7 +2015,8 @@ export declare interface UsingInForOfDeclaration extends BaseNode {
1879
2015
  declare: false;
1880
2016
  /**
1881
2017
  * The keyword used to declare the variable(s)
1882
- * ```
2018
+ * @example
2019
+ * ```ts
1883
2020
  * for(using x of y){}
1884
2021
  * for(await using x of y){}
1885
2022
  * ```
@@ -1903,7 +2040,8 @@ export declare interface UsingInNormalContextDeclaration extends BaseNode {
1903
2040
  /**
1904
2041
  * The variables declared by this declaration.
1905
2042
  * Note that there may be 0 declarations (i.e. `const;`).
1906
- * ```
2043
+ * @example
2044
+ * ```ts
1907
2045
  * using x = 1;
1908
2046
  * using y =1, z = 2;
1909
2047
  * ```
@@ -1916,7 +2054,8 @@ export declare interface UsingInNormalContextDeclaration extends BaseNode {
1916
2054
  declare: false;
1917
2055
  /**
1918
2056
  * The keyword used to declare the variable(s)
1919
- * ```
2057
+ * @example
2058
+ * ```ts
1920
2059
  * using x = 1;
1921
2060
  * await using y = 2;
1922
2061
  * ```