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.
@@ -3729,7 +3729,7 @@ declare namespace ts {
3729
3729
  private enableRequestedPluginsForProjectAsync;
3730
3730
  configurePlugin(args: protocol.ConfigurePluginRequestArguments): void;
3731
3731
  }
3732
- function formatMessage<T extends protocol.Message>(msg: T, logger: Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string;
3732
+ function formatMessage<T extends protocol.Message>(msg: T, logger: Logger, byteLength: (s: string, encoding: BufferEncoding) => number, newLine: string): string;
3733
3733
  interface ServerCancellationToken extends HostCancellationToken {
3734
3734
  setRequest(requestId: number): void;
3735
3735
  resetRequest(requestId: number): void;
@@ -3751,8 +3751,14 @@ declare namespace ts {
3751
3751
  useSingleInferredProject: boolean;
3752
3752
  useInferredProjectPerProjectRoot: boolean;
3753
3753
  typingsInstaller: ITypingsInstaller;
3754
- byteLength: (buf: string, encoding?: string) => number;
3755
- hrtime: (start?: number[]) => number[];
3754
+ byteLength: (buf: string, encoding?: BufferEncoding) => number;
3755
+ hrtime: (start?: [
3756
+ number,
3757
+ number
3758
+ ]) => [
3759
+ number,
3760
+ number
3761
+ ];
3756
3762
  logger: Logger;
3757
3763
  /**
3758
3764
  * If falsy, all events are suppressed.
@@ -3781,7 +3787,7 @@ declare namespace ts {
3781
3787
  protected host: ServerHost;
3782
3788
  private readonly cancellationToken;
3783
3789
  protected readonly typingsInstaller: ITypingsInstaller;
3784
- protected byteLength: (buf: string, encoding?: string) => number;
3790
+ protected byteLength: (buf: string, encoding?: BufferEncoding) => number;
3785
3791
  private hrtime;
3786
3792
  protected logger: Logger;
3787
3793
  protected canUseEvents: boolean;
@@ -4335,14 +4341,15 @@ declare namespace ts {
4335
4341
  JSDocSeeTag = 350,
4336
4342
  JSDocPropertyTag = 351,
4337
4343
  JSDocThrowsTag = 352,
4338
- SyntaxList = 353,
4339
- NotEmittedStatement = 354,
4340
- PartiallyEmittedExpression = 355,
4341
- CommaListExpression = 356,
4342
- MergeDeclarationMarker = 357,
4343
- EndOfDeclarationMarker = 358,
4344
- SyntheticReferenceExpression = 359,
4345
- Count = 360,
4344
+ JSDocSatisfiesTag = 353,
4345
+ SyntaxList = 354,
4346
+ NotEmittedStatement = 355,
4347
+ PartiallyEmittedExpression = 356,
4348
+ CommaListExpression = 357,
4349
+ MergeDeclarationMarker = 358,
4350
+ EndOfDeclarationMarker = 359,
4351
+ SyntheticReferenceExpression = 360,
4352
+ Count = 361,
4346
4353
  FirstAssignment = 63,
4347
4354
  LastAssignment = 78,
4348
4355
  FirstCompoundAssignment = 64,
@@ -4371,9 +4378,9 @@ declare namespace ts {
4371
4378
  LastStatement = 256,
4372
4379
  FirstNode = 163,
4373
4380
  FirstJSDocNode = 312,
4374
- LastJSDocNode = 352,
4381
+ LastJSDocNode = 353,
4375
4382
  FirstJSDocTagNode = 330,
4376
- LastJSDocTagNode = 352
4383
+ LastJSDocTagNode = 353
4377
4384
  }
4378
4385
  type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
4379
4386
  type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -5971,6 +5978,10 @@ declare namespace ts {
5971
5978
  /** If true, then this type literal represents an *array* of its type. */
5972
5979
  readonly isArrayType: boolean;
5973
5980
  }
5981
+ interface JSDocSatisfiesTag extends JSDocTag {
5982
+ readonly kind: SyntaxKind.JSDocSatisfiesTag;
5983
+ readonly typeExpression: JSDocTypeExpression;
5984
+ }
5974
5985
  enum FlowFlags {
5975
5986
  Unreachable = 1,
5976
5987
  Start = 2,
@@ -7817,12 +7828,14 @@ declare namespace ts {
7817
7828
  updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray<JSDocComment> | undefined): JSDocReadonlyTag;
7818
7829
  createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocUnknownTag;
7819
7830
  updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray<JSDocComment> | undefined): JSDocUnknownTag;
7820
- createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
7821
- updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
7822
- createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
7823
- updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
7831
+ createJSDocDeprecatedTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
7832
+ updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocDeprecatedTag;
7833
+ createJSDocOverrideTag(tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
7834
+ updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier | undefined, comment?: string | NodeArray<JSDocComment>): JSDocOverrideTag;
7824
7835
  createJSDocThrowsTag(tagName: Identifier, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment>): JSDocThrowsTag;
7825
7836
  updateJSDocThrowsTag(node: JSDocThrowsTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment?: string | NodeArray<JSDocComment> | undefined): JSDocThrowsTag;
7837
+ createJSDocSatisfiesTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray<JSDocComment>): JSDocSatisfiesTag;
7838
+ updateJSDocSatisfiesTag(node: JSDocSatisfiesTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray<JSDocComment> | undefined): JSDocSatisfiesTag;
7826
7839
  createJSDocText(text: string): JSDocText;
7827
7840
  updateJSDocText(node: JSDocText, text: string): JSDocText;
7828
7841
  createJSDocComment(comment?: string | NodeArray<JSDocComment> | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc;
@@ -8185,16 +8198,39 @@ declare namespace ts {
8185
8198
  /**
8186
8199
  * A function that accepts and possibly transforms a node.
8187
8200
  */
8188
- type Visitor = (node: Node) => VisitResult<Node>;
8201
+ type Visitor<TIn extends Node = Node, TOut extends Node | undefined = TIn | undefined> = (node: TIn) => VisitResult<TOut>;
8202
+ /**
8203
+ * A function that walks a node using the given visitor, lifting node arrays into single nodes,
8204
+ * returning an node which satisfies the test.
8205
+ *
8206
+ * - If the input node is undefined, then the output is undefined.
8207
+ * - If the visitor returns undefined, then the output is undefined.
8208
+ * - If the output node is not undefined, then it will satisfy the test function.
8209
+ * - In order to obtain a return type that is more specific than `Node`, a test
8210
+ * function _must_ be provided, and that function must be a type predicate.
8211
+ *
8212
+ * For the canonical implementation of this type, @see {visitNode}.
8213
+ */
8189
8214
  interface NodeVisitor {
8190
- <T extends Node>(nodes: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T;
8191
- <T extends Node>(nodes: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined;
8215
+ <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);
8216
+ <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);
8192
8217
  }
8218
+ /**
8219
+ * A function that walks a node array using the given visitor, returning an array whose contents satisfy the test.
8220
+ *
8221
+ * - If the input node array is undefined, the output is undefined.
8222
+ * - If the visitor can return undefined, the node it visits in the array will be reused.
8223
+ * - If the output node array is not undefined, then its contents will satisfy the test.
8224
+ * - In order to obtain a return type that is more specific than `NodeArray<Node>`, a test
8225
+ * function _must_ be provided, and that function must be a type predicate.
8226
+ *
8227
+ * For the canonical implementation of this type, @see {visitNodes}.
8228
+ */
8193
8229
  interface NodesVisitor {
8194
- <T extends Node>(nodes: NodeArray<T>, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T>;
8195
- <T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T> | undefined;
8230
+ <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);
8231
+ <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);
8196
8232
  }
8197
- type VisitResult<T extends Node> = T | readonly T[] | undefined;
8233
+ type VisitResult<T extends Node | undefined> = T | readonly Node[];
8198
8234
  interface Printer {
8199
8235
  /**
8200
8236
  * Print a node and its subtree as-is, without any emit transformations.
@@ -8408,6 +8444,7 @@ declare namespace ts {
8408
8444
  }
8409
8445
  type FileWatcherCallback = (fileName: string, eventKind: FileWatcherEventKind, modifiedTime?: Date) => void;
8410
8446
  type DirectoryWatcherCallback = (fileName: string) => void;
8447
+ type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
8411
8448
  interface System {
8412
8449
  args: string[];
8413
8450
  newLine: string;
@@ -8466,8 +8503,8 @@ declare namespace ts {
8466
8503
  function forEachLeadingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined;
8467
8504
  function forEachTrailingCommentRange<U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined;
8468
8505
  function forEachTrailingCommentRange<T, U>(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined;
8469
- 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;
8470
- 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;
8506
+ 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;
8507
+ 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;
8471
8508
  function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
8472
8509
  function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined;
8473
8510
  /** Optionally, get the shebang */
@@ -8546,7 +8583,7 @@ declare namespace ts {
8546
8583
  function getTypeParameterOwner(d: Declaration): Declaration | undefined;
8547
8584
  function isParameterPropertyDeclaration(node: Node, parent: Node): node is ParameterPropertyDeclaration;
8548
8585
  function isEmptyBindingPattern(node: BindingName): node is BindingPattern;
8549
- function isEmptyBindingElement(node: BindingElement): boolean;
8586
+ function isEmptyBindingElement(node: BindingElement | ArrayBindingElement): boolean;
8550
8587
  function walkUpBindingElementsAndPatterns(binding: BindingElement): VariableDeclaration | ParameterDeclaration;
8551
8588
  function getCombinedModifierFlags(node: Declaration): ModifierFlags;
8552
8589
  function getCombinedNodeFlags(node: Node): NodeFlags;
@@ -8563,7 +8600,7 @@ declare namespace ts {
8563
8600
  function getOriginalNode(node: Node): Node;
8564
8601
  function getOriginalNode<T extends Node>(node: Node, nodeTest: (node: Node) => node is T): T;
8565
8602
  function getOriginalNode(node: Node | undefined): Node | undefined;
8566
- function getOriginalNode<T extends Node>(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined;
8603
+ function getOriginalNode<T extends Node>(node: Node | undefined, nodeTest: (node: Node) => node is T): T | undefined;
8567
8604
  /**
8568
8605
  * Iterates through the parent chain of a node and performs the callback on each parent until the callback
8569
8606
  * returns a truthy value, then returns that value.
@@ -8669,6 +8706,7 @@ declare namespace ts {
8669
8706
  function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined;
8670
8707
  /** Gets the JSDoc template tag for the node if present */
8671
8708
  function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined;
8709
+ function getJSDocSatisfiesTag(node: Node): JSDocSatisfiesTag | undefined;
8672
8710
  /** Gets the JSDoc type tag for the node if present and valid */
8673
8711
  function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined;
8674
8712
  /**
@@ -9071,6 +9109,7 @@ declare namespace ts {
9071
9109
  function isJSDocUnknownTag(node: Node): node is JSDocUnknownTag;
9072
9110
  function isJSDocPropertyTag(node: Node): node is JSDocPropertyTag;
9073
9111
  function isJSDocImplementsTag(node: Node): node is JSDocImplementsTag;
9112
+ function isJSDocSatisfiesTag(node: Node): node is JSDocSatisfiesTag;
9074
9113
  function isJSDocThrowsTag(node: Node): node is JSDocThrowsTag;
9075
9114
  function setTextRange<T extends TextRange>(range: T, location: TextRange | undefined): T;
9076
9115
  function canHaveModifiers(node: Node): node is HasModifiers;
@@ -9279,41 +9318,65 @@ declare namespace ts {
9279
9318
  /**
9280
9319
  * Visits a Node using the supplied visitor, possibly returning a new Node in its place.
9281
9320
  *
9321
+ * - If the input node is undefined, then the output is undefined.
9322
+ * - If the visitor returns undefined, then the output is undefined.
9323
+ * - If the output node is not undefined, then it will satisfy the test function.
9324
+ * - In order to obtain a return type that is more specific than `Node`, a test
9325
+ * function _must_ be provided, and that function must be a type predicate.
9326
+ *
9282
9327
  * @param node The Node to visit.
9283
9328
  * @param visitor The callback used to visit the Node.
9284
9329
  * @param test A callback to execute to verify the Node is valid.
9285
9330
  * @param lift An optional callback to execute to lift a NodeArray into a valid Node.
9286
9331
  */
9287
- function visitNode<T extends Node>(node: T, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T;
9332
+ 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);
9288
9333
  /**
9289
9334
  * Visits a Node using the supplied visitor, possibly returning a new Node in its place.
9290
9335
  *
9336
+ * - If the input node is undefined, then the output is undefined.
9337
+ * - If the visitor returns undefined, then the output is undefined.
9338
+ * - If the output node is not undefined, then it will satisfy the test function.
9339
+ * - In order to obtain a return type that is more specific than `Node`, a test
9340
+ * function _must_ be provided, and that function must be a type predicate.
9341
+ *
9291
9342
  * @param node The Node to visit.
9292
9343
  * @param visitor The callback used to visit the Node.
9293
9344
  * @param test A callback to execute to verify the Node is valid.
9294
9345
  * @param lift An optional callback to execute to lift a NodeArray into a valid Node.
9295
9346
  */
9296
- function visitNode<T extends Node>(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: readonly Node[]) => T): T | undefined;
9347
+ 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);
9297
9348
  /**
9298
9349
  * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
9299
9350
  *
9351
+ * - If the input node array is undefined, the output is undefined.
9352
+ * - If the visitor can return undefined, the node it visits in the array will be reused.
9353
+ * - If the output node array is not undefined, then its contents will satisfy the test.
9354
+ * - In order to obtain a return type that is more specific than `NodeArray<Node>`, a test
9355
+ * function _must_ be provided, and that function must be a type predicate.
9356
+ *
9300
9357
  * @param nodes The NodeArray to visit.
9301
9358
  * @param visitor The callback used to visit a Node.
9302
9359
  * @param test A node test to execute for each node.
9303
9360
  * @param start An optional value indicating the starting offset at which to start visiting.
9304
9361
  * @param count An optional value indicating the maximum number of nodes to visit.
9305
9362
  */
9306
- function visitNodes<T extends Node>(nodes: NodeArray<T>, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T>;
9363
+ 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);
9307
9364
  /**
9308
9365
  * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place.
9309
9366
  *
9367
+ * - If the input node array is undefined, the output is undefined.
9368
+ * - If the visitor can return undefined, the node it visits in the array will be reused.
9369
+ * - If the output node array is not undefined, then its contents will satisfy the test.
9370
+ * - In order to obtain a return type that is more specific than `NodeArray<Node>`, a test
9371
+ * function _must_ be provided, and that function must be a type predicate.
9372
+ *
9310
9373
  * @param nodes The NodeArray to visit.
9311
9374
  * @param visitor The callback used to visit a Node.
9312
9375
  * @param test A node test to execute for each node.
9313
9376
  * @param start An optional value indicating the starting offset at which to start visiting.
9314
9377
  * @param count An optional value indicating the maximum number of nodes to visit.
9315
9378
  */
9316
- function visitNodes<T extends Node>(nodes: NodeArray<T> | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray<T> | undefined;
9379
+ 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);
9317
9380
  /**
9318
9381
  * Starts a new lexical environment and visits a statement list, ending the lexical environment
9319
9382
  * and merging hoisted declarations upon completion.