typescript 5.0.0-dev.20230117 → 5.0.0-dev.20230118

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.
@@ -400,14 +400,15 @@ declare namespace ts {
400
400
  JSDocSeeTag = 350,
401
401
  JSDocPropertyTag = 351,
402
402
  JSDocThrowsTag = 352,
403
- SyntaxList = 353,
404
- NotEmittedStatement = 354,
405
- PartiallyEmittedExpression = 355,
406
- CommaListExpression = 356,
407
- MergeDeclarationMarker = 357,
408
- EndOfDeclarationMarker = 358,
409
- SyntheticReferenceExpression = 359,
410
- Count = 360,
403
+ JSDocSatisfiesTag = 353,
404
+ SyntaxList = 354,
405
+ NotEmittedStatement = 355,
406
+ PartiallyEmittedExpression = 356,
407
+ CommaListExpression = 357,
408
+ MergeDeclarationMarker = 358,
409
+ EndOfDeclarationMarker = 359,
410
+ SyntheticReferenceExpression = 360,
411
+ Count = 361,
411
412
  FirstAssignment = 63,
412
413
  LastAssignment = 78,
413
414
  FirstCompoundAssignment = 64,
@@ -436,9 +437,9 @@ declare namespace ts {
436
437
  LastStatement = 256,
437
438
  FirstNode = 163,
438
439
  FirstJSDocNode = 312,
439
- LastJSDocNode = 352,
440
+ LastJSDocNode = 353,
440
441
  FirstJSDocTagNode = 330,
441
- LastJSDocTagNode = 352
442
+ LastJSDocTagNode = 353
442
443
  }
443
444
  type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
444
445
  type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -2036,6 +2037,10 @@ declare namespace ts {
2036
2037
  /** If true, then this type literal represents an *array* of its type. */
2037
2038
  readonly isArrayType: boolean;
2038
2039
  }
2040
+ interface JSDocSatisfiesTag extends JSDocTag {
2041
+ readonly kind: SyntaxKind.JSDocSatisfiesTag;
2042
+ readonly typeExpression: JSDocTypeExpression;
2043
+ }
2039
2044
  enum FlowFlags {
2040
2045
  Unreachable = 1,
2041
2046
  Start = 2,
@@ -3882,12 +3887,14 @@ declare namespace ts {
3882
3887
  updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocReadonlyTag;
3883
3888
  createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocUnknownTag;
3884
3889
  updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocComment> | undefined): JSDocUnknownTag;
3885
- createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
3886
- updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
3887
- createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
3888
- updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
3890
+ createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
3891
+ updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
3892
+ createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
3893
+ updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
3889
3894
  createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment>): JSDocThrowsTag;
3890
3895
  updateJSDocThrowsTag(node: JSDocThrowsTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment> | undefined): JSDocThrowsTag;
3896
+ createJSDocSatisfiesTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray<JSDocComment>): JSDocSatisfiesTag;
3897
+ updateJSDocSatisfiesTag(node: JSDocSatisfiesTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray<JSDocComment> | undefined): JSDocSatisfiesTag;
3891
3898
  createJSDocText(text: string): JSDocText;
3892
3899
  updateJSDocText(node: JSDocText, text: string): JSDocText;
3893
3900
  createJSDocComment(comment?: string | NodeArray<JSDocComment> | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc;
@@ -4250,16 +4257,39 @@ declare namespace ts {
4250
4257
  /**
4251
4258
  * A function that accepts and possibly transforms a node.
4252
4259
  */
4253
- type Visitor = (node: Node) => VisitResult<Node>;
4260
+ type Visitor<TIn extends Node = Node, TOut extends Node | undefined = TIn | undefined> = (node: TIn) => VisitResult<TOut>;
4261
+ /**
4262
+ * A function that walks a node using the given visitor, lifting node arrays into single nodes,
4263
+ * returning an node which satisfies the test.
4264
+ *
4265
+ * - If the input node is undefined, then the output is undefined.
4266
+ * - If the visitor returns undefined, then the output is undefined.
4267
+ * - If the output node is not undefined, then it will satisfy the test function.
4268
+ * - In order to obtain a return type that is more specific than `Node`, a test
4269
+ * function _must_ be provided, and that function must be a type predicate.
4270
+ *
4271
+ * For the canonical implementation of this type, @see {visitNode}.
4272
+ */
4254
4273
  interface NodeVisitor {
4255
- <T extends Node>(nodes: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T;
4256
- <T extends Node>(nodes: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined;
4274
+ <TIn extends Node | undefined, TVisited extends Node | undefined, TOut extends Node>(node: TIn, visitor: Visitor<NonNullable<TIn>, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined);
4275
+ <TIn extends Node | undefined, TVisited extends Node | undefined>(node: TIn, visitor: Visitor<NonNullable<TIn>, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined);
4257
4276
  }
4277
+ /**
4278
+ * A function that walks a node array using the given visitor, returning an array whose contents satisfy the test.
4279
+ *
4280
+ * - If the input node array is undefined, the output is undefined.
4281
+ * - If the visitor can return undefined, the node it visits in the array will be reused.
4282
+ * - If the output node array is not undefined, then its contents will satisfy the test.
4283
+ * - In order to obtain a return type that is more specific than `NodeArray<Node>`, a test
4284
+ * function _must_ be provided, and that function must be a type predicate.
4285
+ *
4286
+ * For the canonical implementation of this type, @see {visitNodes}.
4287
+ */
4258
4288
  interface NodesVisitor {
4259
- <T extends Node>(nodes: NodeArray<T>, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T>;
4260
- <T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T> | undefined;
4289
+ <TIn extends Node, TInArray extends NodeArray<TIn> | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor<TIn, Node | undefined>, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray<TOut> | (TInArray & undefined);
4290
+ <TIn extends Node, TInArray extends NodeArray<TIn> | undefined>(nodes: TInArray, visitor: Visitor<TIn, Node | undefined>, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<Node> | (TInArray & undefined);
4261
4291
  }
4262
- type VisitResult<T extends Node> = T | readonly T[] | undefined;
4292
+ type VisitResult<T extends Node | undefined> = T | readonly Node[];
4263
4293
  interface Printer {
4264
4294
  /**
4265
4295
  * Print a node and its subtree as-is, without any emit transformations.
@@ -4473,6 +4503,7 @@ declare namespace ts {
4473
4503
  }
4474
4504
  type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, modifiedTime?: Date) => void;
4475
4505
  type DirectoryWatcherCallback = (fileName: string) => void;
4506
+ type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
4476
4507
  interface System {
4477
4508
  args: string[];
4478
4509
  newLine: string;
@@ -4531,8 +4562,8 @@ declare namespace ts {
4531
4562
  function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined;
4532
4563
  function forEachTrailingCommentRange<U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined;
4533
4564
  function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined;
4534
- function reduceEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined;
4535
- function reduceEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined;
4565
+ function reduceEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined;
4566
+ function reduceEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T, initial: U): U | undefined;
4536
4567
  function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
4537
4568
  function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
4538
4569
  /** Optionally, get the shebang */
@@ -4611,7 +4642,7 @@ declare namespace ts {
4611
4642
  function getTypeParameterOwner(d: Declaration): Declaration | undefined;
4612
4643
  function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration;
4613
4644
  function isEmptyBindingPattern(node: BindingName): node is BindingPattern;
4614
- function isEmptyBindingElement(node: BindingElement): boolean;
4645
+ function isEmptyBindingElement(node: BindingElement | ArrayBindingElement): boolean;
4615
4646
  function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration;
4616
4647
  function getCombinedModifierFlags(node: Declaration): ModifierFlags;
4617
4648
  function getCombinedNodeFlags(node: Node): NodeFlags;
@@ -4628,7 +4659,7 @@ declare namespace ts {
4628
4659
  function getOriginalNode(node: Node): Node;
4629
4660
  function getOriginalNode<T extends Node>(node: Node, nodeTest: (node: Node) => node is T): T;
4630
4661
  function getOriginalNode(node: Node | undefined): Node | undefined;
4631
- function getOriginalNode<T extends Node>(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined;
4662
+ function getOriginalNode<T extends Node>(node: Node | undefined, nodeTest: (node: Node) => node is T): T | undefined;
4632
4663
  /**
4633
4664
  * Iterates through the parent chain of a node and performs the callback on each parent until the callback
4634
4665
  * returns a truthy value, then returns that value.
@@ -4734,6 +4765,7 @@ declare namespace ts {
4734
4765
  function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined;
4735
4766
  /** Gets the JSDoc template tag for the node if present */
4736
4767
  function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined;
4768
+ function getJSDocSatisfiesTag(node: Node): JSDocSatisfiesTag | undefined;
4737
4769
  /** Gets the JSDoc type tag for the node if present and valid */
4738
4770
  function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined;
4739
4771
  /**
@@ -5136,6 +5168,7 @@ declare namespace ts {
5136
5168
  function isJSDocUnknownTag(node: Node): node is JSDocUnknownTag;
5137
5169
  function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag;
5138
5170
  function isJSDocImplementsTag(node: Node): node is JSDocImplementsTag;
5171
+ function isJSDocSatisfiesTag(node: Node): node is JSDocSatisfiesTag;
5139
5172
  function isJSDocThrowsTag(node: Node): node is JSDocThrowsTag;
5140
5173
  function setTextRange<T extends TextRange>(range: T, location: TextRange | undefined): T;
5141
5174
  function canHaveModifiers(node: Node): node is HasModifiers;
@@ -5344,41 +5377,65 @@ declare namespace ts {
5344
5377
  /**
5345
5378
  * Visits a Node using the supplied visitor, possibly returning a new Node in its place.
5346
5379
  *
5380
+ * - If the input node is undefined, then the output is undefined.
5381
+ * - If the visitor returns undefined, then the output is undefined.
5382
+ * - If the output node is not undefined, then it will satisfy the test function.
5383
+ * - In order to obtain a return type that is more specific than `Node`, a test
5384
+ * function _must_ be provided, and that function must be a type predicate.
5385
+ *
5347
5386
  * @param node The Node to visit.
5348
5387
  * @param visitor The callback used to visit the Node.
5349
5388
  * @param test A callback to execute to verify the Node is valid.
5350
5389
  * @param lift An optional callback to execute to lift a NodeArray into a valid Node.
5351
5390
  */
5352
- function visitNode<T extends Node>(node: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T;
5391
+ function visitNode<TIn extends Node | undefined, TVisited extends Node | undefined, TOut extends Node>(node: TIn, visitor: Visitor<NonNullable<TIn>, TVisited>, test: (node: Node) => node is TOut, lift?: (node: readonly Node[]) => Node): TOut | (TIn & undefined) | (TVisited & undefined);
5353
5392
  /**
5354
5393
  * Visits a Node using the supplied visitor, possibly returning a new Node in its place.
5355
5394
  *
5395
+ * - If the input node is undefined, then the output is undefined.
5396
+ * - If the visitor returns undefined, then the output is undefined.
5397
+ * - If the output node is not undefined, then it will satisfy the test function.
5398
+ * - In order to obtain a return type that is more specific than `Node`, a test
5399
+ * function _must_ be provided, and that function must be a type predicate.
5400
+ *
5356
5401
  * @param node The Node to visit.
5357
5402
  * @param visitor The callback used to visit the Node.
5358
5403
  * @param test A callback to execute to verify the Node is valid.
5359
5404
  * @param lift An optional callback to execute to lift a NodeArray into a valid Node.
5360
5405
  */
5361
- function visitNode<T extends Node>(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined;
5406
+ function visitNode<TIn extends Node | undefined, TVisited extends Node | undefined>(node: TIn, visitor: Visitor<NonNullable<TIn>, TVisited>, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => Node): Node | (TIn & undefined) | (TVisited & undefined);
5362
5407
  /**
5363
5408
  * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
5364
5409
  *
5410
+ * - If the input node array is undefined, the output is undefined.
5411
+ * - If the visitor can return undefined, the node it visits in the array will be reused.
5412
+ * - If the output node array is not undefined, then its contents will satisfy the test.
5413
+ * - In order to obtain a return type that is more specific than `NodeArray<Node>`, a test
5414
+ * function _must_ be provided, and that function must be a type predicate.
5415
+ *
5365
5416
  * @param nodes The NodeArray to visit.
5366
5417
  * @param visitor The callback used to visit a Node.
5367
5418
  * @param test A node test to execute for each node.
5368
5419
  * @param start An optional value indicating the starting offset at which to start visiting.
5369
5420
  * @param count An optional value indicating the maximum number of nodes to visit.
5370
5421
  */
5371
- function visitNodes<T extends Node>(nodes: NodeArray<T>, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T>;
5422
+ function visitNodes<TIn extends Node, TInArray extends NodeArray<TIn> | undefined, TOut extends Node>(nodes: TInArray, visitor: Visitor<TIn, Node | undefined>, test: (node: Node) => node is TOut, start?: number, count?: number): NodeArray<TOut> | (TInArray & undefined);
5372
5423
  /**
5373
5424
  * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
5374
5425
  *
5426
+ * - If the input node array is undefined, the output is undefined.
5427
+ * - If the visitor can return undefined, the node it visits in the array will be reused.
5428
+ * - If the output node array is not undefined, then its contents will satisfy the test.
5429
+ * - In order to obtain a return type that is more specific than `NodeArray<Node>`, a test
5430
+ * function _must_ be provided, and that function must be a type predicate.
5431
+ *
5375
5432
  * @param nodes The NodeArray to visit.
5376
5433
  * @param visitor The callback used to visit a Node.
5377
5434
  * @param test A node test to execute for each node.
5378
5435
  * @param start An optional value indicating the starting offset at which to start visiting.
5379
5436
  * @param count An optional value indicating the maximum number of nodes to visit.
5380
5437
  */
5381
- function visitNodes<T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T> | undefined;
5438
+ function visitNodes<TIn extends Node, TInArray extends NodeArray<TIn> | undefined>(nodes: TInArray, visitor: Visitor<TIn, Node | undefined>, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<Node> | (TInArray & undefined);
5382
5439
  /**
5383
5440
  * Starts a new lexical environment and visits a statement list, ending the lexical environment
5384
5441
  * and merging hoisted declarations upon completion.