typescript 5.2.0-dev.20230721 → 5.2.0-dev.20230723

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.
package/lib/tsc.js CHANGED
@@ -18,7 +18,7 @@ and limitations under the License.
18
18
 
19
19
  // src/compiler/corePublic.ts
20
20
  var versionMajorMinor = "5.2";
21
- var version = `${versionMajorMinor}.0-dev.20230721`;
21
+ var version = `${versionMajorMinor}.0-dev.20230723`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -33524,7 +33524,7 @@ function getNamedArgRegEx(name) {
33524
33524
  return result;
33525
33525
  }
33526
33526
  var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
33527
- var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
33527
+ var singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
33528
33528
  function extractPragmas(pragmas, range, text) {
33529
33529
  const tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
33530
33530
  if (tripleSlash) {
package/lib/tsserver.js CHANGED
@@ -2329,7 +2329,7 @@ module.exports = __toCommonJS(server_exports);
2329
2329
 
2330
2330
  // src/compiler/corePublic.ts
2331
2331
  var versionMajorMinor = "5.2";
2332
- var version = `${versionMajorMinor}.0-dev.20230721`;
2332
+ var version = `${versionMajorMinor}.0-dev.20230723`;
2333
2333
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2334
2334
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2335
2335
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -37924,7 +37924,7 @@ function getNamedArgRegEx(name) {
37924
37924
  return result;
37925
37925
  }
37926
37926
  var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
37927
- var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
37927
+ var singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
37928
37928
  function extractPragmas(pragmas, range, text) {
37929
37929
  const tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
37930
37930
  if (tripleSlash) {
@@ -136047,8 +136047,8 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
136047
136047
  diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
136048
136048
  }
136049
136049
  }
136050
- const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
136051
- if (jsdocTypedefNode) {
136050
+ const jsdocTypedefNodes = ts_codefix_exports.getJSDocTypedefNodes(node);
136051
+ for (const jsdocTypedefNode of jsdocTypedefNodes) {
136052
136052
  diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
136053
136053
  }
136054
136054
  if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
@@ -146867,7 +146867,7 @@ __export(ts_codefix_exports, {
146867
146867
  getFixes: () => getFixes,
146868
146868
  getImportCompletionAction: () => getImportCompletionAction,
146869
146869
  getImportKind: () => getImportKind,
146870
- getJSDocTypedefNode: () => getJSDocTypedefNode,
146870
+ getJSDocTypedefNodes: () => getJSDocTypedefNodes,
146871
146871
  getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
146872
146872
  getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
146873
146873
  getSupportedErrorCodes: () => getSupportedErrorCodes,
@@ -149589,13 +149589,14 @@ registerCodeFix({
149589
149589
  fixIds: [fixId14],
149590
149590
  errorCodes: errorCodes15,
149591
149591
  getCodeActions(context) {
149592
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
149592
149593
  const node = getTokenAtPosition(
149593
149594
  context.sourceFile,
149594
149595
  context.span.start
149595
149596
  );
149596
149597
  if (!node)
149597
149598
  return;
149598
- const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile));
149599
+ const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile, newLineCharacter));
149599
149600
  if (changes.length > 0) {
149600
149601
  return [
149601
149602
  createCodeFixAction(
@@ -149608,29 +149609,72 @@ registerCodeFix({
149608
149609
  ];
149609
149610
  }
149610
149611
  },
149611
- getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
149612
- const node = getTokenAtPosition(diag2.file, diag2.start);
149613
- if (node)
149614
- doChange12(changes, node, diag2.file);
149615
- })
149612
+ getAllCodeActions: (context) => codeFixAll(
149613
+ context,
149614
+ errorCodes15,
149615
+ (changes, diag2) => {
149616
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
149617
+ const node = getTokenAtPosition(diag2.file, diag2.start);
149618
+ const fixAll = true;
149619
+ if (node)
149620
+ doChange12(changes, node, diag2.file, newLineCharacter, fixAll);
149621
+ }
149622
+ )
149616
149623
  });
149617
- function doChange12(changes, node, sourceFile) {
149618
- if (isJSDocTypedefTag(node)) {
149619
- fixSingleTypeDef(changes, node, sourceFile);
149620
- }
149621
- }
149622
- function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
149623
- if (!typeDefNode)
149624
+ function doChange12(changes, node, sourceFile, newLine, fixAll = false) {
149625
+ if (!isJSDocTypedefTag(node))
149624
149626
  return;
149625
- const declaration = createDeclaration(typeDefNode);
149627
+ const declaration = createDeclaration(node);
149626
149628
  if (!declaration)
149627
149629
  return;
149628
- const comment = typeDefNode.parent;
149629
- changes.replaceNode(
149630
- sourceFile,
149631
- comment,
149632
- declaration
149630
+ const commentNode = node.parent;
149631
+ const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
149632
+ let pos = commentNode.getStart();
149633
+ let prefix = "";
149634
+ if (!leftSibling && commentNode.comment) {
149635
+ pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
149636
+ prefix = `${newLine} */${newLine}`;
149637
+ }
149638
+ if (leftSibling) {
149639
+ if (fixAll && isJSDocTypedefTag(leftSibling)) {
149640
+ pos = node.getStart();
149641
+ prefix = "";
149642
+ } else {
149643
+ pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
149644
+ prefix = `${newLine} */${newLine}`;
149645
+ }
149646
+ }
149647
+ let end = commentNode.getEnd();
149648
+ let suffix = "";
149649
+ if (rightSibling) {
149650
+ if (fixAll && isJSDocTypedefTag(rightSibling)) {
149651
+ end = rightSibling.getStart();
149652
+ suffix = `${newLine}${newLine}`;
149653
+ } else {
149654
+ end = rightSibling.getStart();
149655
+ suffix = `${newLine}/**${newLine} * `;
149656
+ }
149657
+ }
149658
+ changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
149659
+ }
149660
+ function getLeftAndRightSiblings(typedefNode) {
149661
+ const commentNode = typedefNode.parent;
149662
+ const maxChildIndex = commentNode.getChildCount() - 1;
149663
+ const currentNodeIndex = commentNode.getChildren().findIndex(
149664
+ (n) => n.getStart() === typedefNode.getStart() && n.getEnd() === typedefNode.getEnd()
149633
149665
  );
149666
+ const leftSibling = currentNodeIndex > 0 ? commentNode.getChildAt(currentNodeIndex - 1) : void 0;
149667
+ const rightSibling = currentNodeIndex < maxChildIndex ? commentNode.getChildAt(currentNodeIndex + 1) : void 0;
149668
+ return { leftSibling, rightSibling };
149669
+ }
149670
+ function findEndOfTextBetween(jsDocComment, from, to) {
149671
+ const comment = jsDocComment.getText().substring(from - jsDocComment.getStart(), to - jsDocComment.getStart());
149672
+ for (let i = comment.length; i > 0; i--) {
149673
+ if (!/[*\/\s]/g.test(comment.substring(i - 1, i))) {
149674
+ return from + i;
149675
+ }
149676
+ }
149677
+ return to;
149634
149678
  }
149635
149679
  function createDeclaration(tag) {
149636
149680
  var _a;
@@ -149651,7 +149695,7 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
149651
149695
  const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
149652
149696
  if (!some(propertySignatures))
149653
149697
  return;
149654
- const interfaceDeclaration = factory.createInterfaceDeclaration(
149698
+ return factory.createInterfaceDeclaration(
149655
149699
  /*modifiers*/
149656
149700
  void 0,
149657
149701
  typeName,
@@ -149661,13 +149705,12 @@ function createInterfaceForTypeLiteral(typeName, typeLiteral) {
149661
149705
  void 0,
149662
149706
  propertySignatures
149663
149707
  );
149664
- return interfaceDeclaration;
149665
149708
  }
149666
149709
  function createTypeAliasForTypeExpression(typeName, typeExpression) {
149667
149710
  const typeReference = getSynthesizedDeepClone(typeExpression.type);
149668
149711
  if (!typeReference)
149669
149712
  return;
149670
- const declaration = factory.createTypeAliasDeclaration(
149713
+ return factory.createTypeAliasDeclaration(
149671
149714
  /*modifiers*/
149672
149715
  void 0,
149673
149716
  factory.createIdentifier(typeName),
@@ -149675,7 +149718,6 @@ function createTypeAliasForTypeExpression(typeName, typeExpression) {
149675
149718
  void 0,
149676
149719
  typeReference
149677
149720
  );
149678
- return declaration;
149679
149721
  }
149680
149722
  function createSignatureFromTypeLiteral(typeLiteral) {
149681
149723
  const propertyTags = typeLiteral.jsDocPropertyTags;
@@ -149695,30 +149737,28 @@ function createSignatureFromTypeLiteral(typeLiteral) {
149695
149737
  }
149696
149738
  if (typeReference && name) {
149697
149739
  const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
149698
- const prop = factory.createPropertySignature(
149740
+ return factory.createPropertySignature(
149699
149741
  /*modifiers*/
149700
149742
  void 0,
149701
149743
  name,
149702
149744
  questionToken,
149703
149745
  typeReference
149704
149746
  );
149705
- return prop;
149706
149747
  }
149707
149748
  };
149708
- const props = mapDefined(propertyTags, getSignature);
149709
- return props;
149749
+ return mapDefined(propertyTags, getSignature);
149710
149750
  }
149711
149751
  function getPropertyName(tag) {
149712
149752
  return tag.name.kind === 80 /* Identifier */ ? tag.name.text : tag.name.right.text;
149713
149753
  }
149714
- function getJSDocTypedefNode(node) {
149754
+ function getJSDocTypedefNodes(node) {
149715
149755
  if (hasJSDocNodes(node)) {
149716
- return forEach(node.jsDoc, (node2) => {
149756
+ return flatMap(node.jsDoc, (doc) => {
149717
149757
  var _a;
149718
- return (_a = node2.tags) == null ? void 0 : _a.find(isJSDocTypedefTag);
149758
+ return (_a = doc.tags) == null ? void 0 : _a.filter((tag) => isJSDocTypedefTag(tag));
149719
149759
  });
149720
149760
  }
149721
- return void 0;
149761
+ return [];
149722
149762
  }
149723
149763
 
149724
149764
  // src/services/codefixes/convertLiteralTypeToMappedType.ts
@@ -151968,6 +152008,8 @@ function getInfo9(checker, sourceFile, position, errorCode) {
151968
152008
  if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
151969
152009
  return void 0;
151970
152010
  const pos = declaration.parent.arguments.indexOf(declaration);
152011
+ if (pos === -1)
152012
+ return void 0;
151971
152013
  const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
151972
152014
  if (!type)
151973
152015
  return void 0;
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.2";
38
- version = `${versionMajorMinor}.0-dev.20230721`;
38
+ version = `${versionMajorMinor}.0-dev.20230723`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -35877,7 +35877,7 @@ ${lanes.join("\n")}
35877
35877
  })(IncrementalParser || (IncrementalParser = {}));
35878
35878
  namedArgRegExCache = /* @__PURE__ */ new Map();
35879
35879
  tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
35880
- singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
35880
+ singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
35881
35881
  }
35882
35882
  });
35883
35883
 
@@ -134411,8 +134411,8 @@ ${lanes.join("\n")}
134411
134411
  diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
134412
134412
  }
134413
134413
  }
134414
- const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
134415
- if (jsdocTypedefNode) {
134414
+ const jsdocTypedefNodes = ts_codefix_exports.getJSDocTypedefNodes(node);
134415
+ for (const jsdocTypedefNode of jsdocTypedefNodes) {
134416
134416
  diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
134417
134417
  }
134418
134418
  if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
@@ -148340,23 +148340,60 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148340
148340
  });
148341
148341
 
148342
148342
  // src/services/codefixes/convertTypedefToType.ts
148343
- function doChange12(changes, node, sourceFile) {
148344
- if (isJSDocTypedefTag(node)) {
148345
- fixSingleTypeDef(changes, node, sourceFile);
148346
- }
148347
- }
148348
- function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
148349
- if (!typeDefNode)
148343
+ function doChange12(changes, node, sourceFile, newLine, fixAll = false) {
148344
+ if (!isJSDocTypedefTag(node))
148350
148345
  return;
148351
- const declaration = createDeclaration(typeDefNode);
148346
+ const declaration = createDeclaration(node);
148352
148347
  if (!declaration)
148353
148348
  return;
148354
- const comment = typeDefNode.parent;
148355
- changes.replaceNode(
148356
- sourceFile,
148357
- comment,
148358
- declaration
148349
+ const commentNode = node.parent;
148350
+ const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
148351
+ let pos = commentNode.getStart();
148352
+ let prefix = "";
148353
+ if (!leftSibling && commentNode.comment) {
148354
+ pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
148355
+ prefix = `${newLine} */${newLine}`;
148356
+ }
148357
+ if (leftSibling) {
148358
+ if (fixAll && isJSDocTypedefTag(leftSibling)) {
148359
+ pos = node.getStart();
148360
+ prefix = "";
148361
+ } else {
148362
+ pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
148363
+ prefix = `${newLine} */${newLine}`;
148364
+ }
148365
+ }
148366
+ let end = commentNode.getEnd();
148367
+ let suffix = "";
148368
+ if (rightSibling) {
148369
+ if (fixAll && isJSDocTypedefTag(rightSibling)) {
148370
+ end = rightSibling.getStart();
148371
+ suffix = `${newLine}${newLine}`;
148372
+ } else {
148373
+ end = rightSibling.getStart();
148374
+ suffix = `${newLine}/**${newLine} * `;
148375
+ }
148376
+ }
148377
+ changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
148378
+ }
148379
+ function getLeftAndRightSiblings(typedefNode) {
148380
+ const commentNode = typedefNode.parent;
148381
+ const maxChildIndex = commentNode.getChildCount() - 1;
148382
+ const currentNodeIndex = commentNode.getChildren().findIndex(
148383
+ (n) => n.getStart() === typedefNode.getStart() && n.getEnd() === typedefNode.getEnd()
148359
148384
  );
148385
+ const leftSibling = currentNodeIndex > 0 ? commentNode.getChildAt(currentNodeIndex - 1) : void 0;
148386
+ const rightSibling = currentNodeIndex < maxChildIndex ? commentNode.getChildAt(currentNodeIndex + 1) : void 0;
148387
+ return { leftSibling, rightSibling };
148388
+ }
148389
+ function findEndOfTextBetween(jsDocComment, from, to) {
148390
+ const comment = jsDocComment.getText().substring(from - jsDocComment.getStart(), to - jsDocComment.getStart());
148391
+ for (let i = comment.length; i > 0; i--) {
148392
+ if (!/[*\/\s]/g.test(comment.substring(i - 1, i))) {
148393
+ return from + i;
148394
+ }
148395
+ }
148396
+ return to;
148360
148397
  }
148361
148398
  function createDeclaration(tag) {
148362
148399
  var _a;
@@ -148377,7 +148414,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148377
148414
  const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
148378
148415
  if (!some(propertySignatures))
148379
148416
  return;
148380
- const interfaceDeclaration = factory.createInterfaceDeclaration(
148417
+ return factory.createInterfaceDeclaration(
148381
148418
  /*modifiers*/
148382
148419
  void 0,
148383
148420
  typeName,
@@ -148387,13 +148424,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148387
148424
  void 0,
148388
148425
  propertySignatures
148389
148426
  );
148390
- return interfaceDeclaration;
148391
148427
  }
148392
148428
  function createTypeAliasForTypeExpression(typeName, typeExpression) {
148393
148429
  const typeReference = getSynthesizedDeepClone(typeExpression.type);
148394
148430
  if (!typeReference)
148395
148431
  return;
148396
- const declaration = factory.createTypeAliasDeclaration(
148432
+ return factory.createTypeAliasDeclaration(
148397
148433
  /*modifiers*/
148398
148434
  void 0,
148399
148435
  factory.createIdentifier(typeName),
@@ -148401,7 +148437,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148401
148437
  void 0,
148402
148438
  typeReference
148403
148439
  );
148404
- return declaration;
148405
148440
  }
148406
148441
  function createSignatureFromTypeLiteral(typeLiteral) {
148407
148442
  const propertyTags = typeLiteral.jsDocPropertyTags;
@@ -148421,30 +148456,28 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148421
148456
  }
148422
148457
  if (typeReference && name) {
148423
148458
  const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
148424
- const prop = factory.createPropertySignature(
148459
+ return factory.createPropertySignature(
148425
148460
  /*modifiers*/
148426
148461
  void 0,
148427
148462
  name,
148428
148463
  questionToken,
148429
148464
  typeReference
148430
148465
  );
148431
- return prop;
148432
148466
  }
148433
148467
  };
148434
- const props = mapDefined(propertyTags, getSignature);
148435
- return props;
148468
+ return mapDefined(propertyTags, getSignature);
148436
148469
  }
148437
148470
  function getPropertyName(tag) {
148438
148471
  return tag.name.kind === 80 /* Identifier */ ? tag.name.text : tag.name.right.text;
148439
148472
  }
148440
- function getJSDocTypedefNode(node) {
148473
+ function getJSDocTypedefNodes(node) {
148441
148474
  if (hasJSDocNodes(node)) {
148442
- return forEach(node.jsDoc, (node2) => {
148475
+ return flatMap(node.jsDoc, (doc) => {
148443
148476
  var _a;
148444
- return (_a = node2.tags) == null ? void 0 : _a.find(isJSDocTypedefTag);
148477
+ return (_a = doc.tags) == null ? void 0 : _a.filter((tag) => isJSDocTypedefTag(tag));
148445
148478
  });
148446
148479
  }
148447
- return void 0;
148480
+ return [];
148448
148481
  }
148449
148482
  var fixId14, errorCodes15;
148450
148483
  var init_convertTypedefToType = __esm({
@@ -148458,13 +148491,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148458
148491
  fixIds: [fixId14],
148459
148492
  errorCodes: errorCodes15,
148460
148493
  getCodeActions(context) {
148494
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
148461
148495
  const node = getTokenAtPosition(
148462
148496
  context.sourceFile,
148463
148497
  context.span.start
148464
148498
  );
148465
148499
  if (!node)
148466
148500
  return;
148467
- const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile));
148501
+ const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile, newLineCharacter));
148468
148502
  if (changes.length > 0) {
148469
148503
  return [
148470
148504
  createCodeFixAction(
@@ -148477,11 +148511,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148477
148511
  ];
148478
148512
  }
148479
148513
  },
148480
- getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
148481
- const node = getTokenAtPosition(diag2.file, diag2.start);
148482
- if (node)
148483
- doChange12(changes, node, diag2.file);
148484
- })
148514
+ getAllCodeActions: (context) => codeFixAll(
148515
+ context,
148516
+ errorCodes15,
148517
+ (changes, diag2) => {
148518
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
148519
+ const node = getTokenAtPosition(diag2.file, diag2.start);
148520
+ const fixAll = true;
148521
+ if (node)
148522
+ doChange12(changes, node, diag2.file, newLineCharacter, fixAll);
148523
+ }
148524
+ )
148485
148525
  });
148486
148526
  }
148487
148527
  });
@@ -150756,6 +150796,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
150756
150796
  if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
150757
150797
  return void 0;
150758
150798
  const pos = declaration.parent.arguments.indexOf(declaration);
150799
+ if (pos === -1)
150800
+ return void 0;
150759
150801
  const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
150760
150802
  if (!type)
150761
150803
  return void 0;
@@ -156004,7 +156046,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
156004
156046
  getFixes: () => getFixes,
156005
156047
  getImportCompletionAction: () => getImportCompletionAction,
156006
156048
  getImportKind: () => getImportKind,
156007
- getJSDocTypedefNode: () => getJSDocTypedefNode,
156049
+ getJSDocTypedefNodes: () => getJSDocTypedefNodes,
156008
156050
  getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
156009
156051
  getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
156010
156052
  getSupportedErrorCodes: () => getSupportedErrorCodes,
package/lib/typescript.js CHANGED
@@ -35,7 +35,7 @@ var ts = (() => {
35
35
  "src/compiler/corePublic.ts"() {
36
36
  "use strict";
37
37
  versionMajorMinor = "5.2";
38
- version = `${versionMajorMinor}.0-dev.20230721`;
38
+ version = `${versionMajorMinor}.0-dev.20230723`;
39
39
  Comparison = /* @__PURE__ */ ((Comparison3) => {
40
40
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
41
41
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -35877,7 +35877,7 @@ ${lanes.join("\n")}
35877
35877
  })(IncrementalParser || (IncrementalParser = {}));
35878
35878
  namedArgRegExCache = /* @__PURE__ */ new Map();
35879
35879
  tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
35880
- singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
35880
+ singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
35881
35881
  }
35882
35882
  });
35883
35883
 
@@ -134426,8 +134426,8 @@ ${lanes.join("\n")}
134426
134426
  diags.push(createDiagnosticForNode(init, Diagnostics.require_call_may_be_converted_to_an_import));
134427
134427
  }
134428
134428
  }
134429
- const jsdocTypedefNode = ts_codefix_exports.getJSDocTypedefNode(node);
134430
- if (jsdocTypedefNode) {
134429
+ const jsdocTypedefNodes = ts_codefix_exports.getJSDocTypedefNodes(node);
134430
+ for (const jsdocTypedefNode of jsdocTypedefNodes) {
134431
134431
  diags.push(createDiagnosticForNode(jsdocTypedefNode, Diagnostics.JSDoc_typedef_may_be_converted_to_TypeScript_type));
134432
134432
  }
134433
134433
  if (ts_codefix_exports.parameterShouldGetTypeFromJSDoc(node)) {
@@ -148355,23 +148355,60 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148355
148355
  });
148356
148356
 
148357
148357
  // src/services/codefixes/convertTypedefToType.ts
148358
- function doChange12(changes, node, sourceFile) {
148359
- if (isJSDocTypedefTag(node)) {
148360
- fixSingleTypeDef(changes, node, sourceFile);
148361
- }
148362
- }
148363
- function fixSingleTypeDef(changes, typeDefNode, sourceFile) {
148364
- if (!typeDefNode)
148358
+ function doChange12(changes, node, sourceFile, newLine, fixAll = false) {
148359
+ if (!isJSDocTypedefTag(node))
148365
148360
  return;
148366
- const declaration = createDeclaration(typeDefNode);
148361
+ const declaration = createDeclaration(node);
148367
148362
  if (!declaration)
148368
148363
  return;
148369
- const comment = typeDefNode.parent;
148370
- changes.replaceNode(
148371
- sourceFile,
148372
- comment,
148373
- declaration
148364
+ const commentNode = node.parent;
148365
+ const { leftSibling, rightSibling } = getLeftAndRightSiblings(node);
148366
+ let pos = commentNode.getStart();
148367
+ let prefix = "";
148368
+ if (!leftSibling && commentNode.comment) {
148369
+ pos = findEndOfTextBetween(commentNode, commentNode.getStart(), node.getStart());
148370
+ prefix = `${newLine} */${newLine}`;
148371
+ }
148372
+ if (leftSibling) {
148373
+ if (fixAll && isJSDocTypedefTag(leftSibling)) {
148374
+ pos = node.getStart();
148375
+ prefix = "";
148376
+ } else {
148377
+ pos = findEndOfTextBetween(commentNode, leftSibling.getStart(), node.getStart());
148378
+ prefix = `${newLine} */${newLine}`;
148379
+ }
148380
+ }
148381
+ let end = commentNode.getEnd();
148382
+ let suffix = "";
148383
+ if (rightSibling) {
148384
+ if (fixAll && isJSDocTypedefTag(rightSibling)) {
148385
+ end = rightSibling.getStart();
148386
+ suffix = `${newLine}${newLine}`;
148387
+ } else {
148388
+ end = rightSibling.getStart();
148389
+ suffix = `${newLine}/**${newLine} * `;
148390
+ }
148391
+ }
148392
+ changes.replaceRange(sourceFile, { pos, end }, declaration, { prefix, suffix });
148393
+ }
148394
+ function getLeftAndRightSiblings(typedefNode) {
148395
+ const commentNode = typedefNode.parent;
148396
+ const maxChildIndex = commentNode.getChildCount() - 1;
148397
+ const currentNodeIndex = commentNode.getChildren().findIndex(
148398
+ (n) => n.getStart() === typedefNode.getStart() && n.getEnd() === typedefNode.getEnd()
148374
148399
  );
148400
+ const leftSibling = currentNodeIndex > 0 ? commentNode.getChildAt(currentNodeIndex - 1) : void 0;
148401
+ const rightSibling = currentNodeIndex < maxChildIndex ? commentNode.getChildAt(currentNodeIndex + 1) : void 0;
148402
+ return { leftSibling, rightSibling };
148403
+ }
148404
+ function findEndOfTextBetween(jsDocComment, from, to) {
148405
+ const comment = jsDocComment.getText().substring(from - jsDocComment.getStart(), to - jsDocComment.getStart());
148406
+ for (let i = comment.length; i > 0; i--) {
148407
+ if (!/[*\/\s]/g.test(comment.substring(i - 1, i))) {
148408
+ return from + i;
148409
+ }
148410
+ }
148411
+ return to;
148375
148412
  }
148376
148413
  function createDeclaration(tag) {
148377
148414
  var _a;
@@ -148392,7 +148429,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148392
148429
  const propertySignatures = createSignatureFromTypeLiteral(typeLiteral);
148393
148430
  if (!some(propertySignatures))
148394
148431
  return;
148395
- const interfaceDeclaration = factory.createInterfaceDeclaration(
148432
+ return factory.createInterfaceDeclaration(
148396
148433
  /*modifiers*/
148397
148434
  void 0,
148398
148435
  typeName,
@@ -148402,13 +148439,12 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148402
148439
  void 0,
148403
148440
  propertySignatures
148404
148441
  );
148405
- return interfaceDeclaration;
148406
148442
  }
148407
148443
  function createTypeAliasForTypeExpression(typeName, typeExpression) {
148408
148444
  const typeReference = getSynthesizedDeepClone(typeExpression.type);
148409
148445
  if (!typeReference)
148410
148446
  return;
148411
- const declaration = factory.createTypeAliasDeclaration(
148447
+ return factory.createTypeAliasDeclaration(
148412
148448
  /*modifiers*/
148413
148449
  void 0,
148414
148450
  factory.createIdentifier(typeName),
@@ -148416,7 +148452,6 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148416
148452
  void 0,
148417
148453
  typeReference
148418
148454
  );
148419
- return declaration;
148420
148455
  }
148421
148456
  function createSignatureFromTypeLiteral(typeLiteral) {
148422
148457
  const propertyTags = typeLiteral.jsDocPropertyTags;
@@ -148436,30 +148471,28 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148436
148471
  }
148437
148472
  if (typeReference && name) {
148438
148473
  const questionToken = isOptional ? factory.createToken(58 /* QuestionToken */) : void 0;
148439
- const prop = factory.createPropertySignature(
148474
+ return factory.createPropertySignature(
148440
148475
  /*modifiers*/
148441
148476
  void 0,
148442
148477
  name,
148443
148478
  questionToken,
148444
148479
  typeReference
148445
148480
  );
148446
- return prop;
148447
148481
  }
148448
148482
  };
148449
- const props = mapDefined(propertyTags, getSignature);
148450
- return props;
148483
+ return mapDefined(propertyTags, getSignature);
148451
148484
  }
148452
148485
  function getPropertyName(tag) {
148453
148486
  return tag.name.kind === 80 /* Identifier */ ? tag.name.text : tag.name.right.text;
148454
148487
  }
148455
- function getJSDocTypedefNode(node) {
148488
+ function getJSDocTypedefNodes(node) {
148456
148489
  if (hasJSDocNodes(node)) {
148457
- return forEach(node.jsDoc, (node2) => {
148490
+ return flatMap(node.jsDoc, (doc) => {
148458
148491
  var _a;
148459
- return (_a = node2.tags) == null ? void 0 : _a.find(isJSDocTypedefTag);
148492
+ return (_a = doc.tags) == null ? void 0 : _a.filter((tag) => isJSDocTypedefTag(tag));
148460
148493
  });
148461
148494
  }
148462
- return void 0;
148495
+ return [];
148463
148496
  }
148464
148497
  var fixId14, errorCodes15;
148465
148498
  var init_convertTypedefToType = __esm({
@@ -148473,13 +148506,14 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148473
148506
  fixIds: [fixId14],
148474
148507
  errorCodes: errorCodes15,
148475
148508
  getCodeActions(context) {
148509
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
148476
148510
  const node = getTokenAtPosition(
148477
148511
  context.sourceFile,
148478
148512
  context.span.start
148479
148513
  );
148480
148514
  if (!node)
148481
148515
  return;
148482
- const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile));
148516
+ const changes = ts_textChanges_exports.ChangeTracker.with(context, (t) => doChange12(t, node, context.sourceFile, newLineCharacter));
148483
148517
  if (changes.length > 0) {
148484
148518
  return [
148485
148519
  createCodeFixAction(
@@ -148492,11 +148526,17 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
148492
148526
  ];
148493
148527
  }
148494
148528
  },
148495
- getAllCodeActions: (context) => codeFixAll(context, errorCodes15, (changes, diag2) => {
148496
- const node = getTokenAtPosition(diag2.file, diag2.start);
148497
- if (node)
148498
- doChange12(changes, node, diag2.file);
148499
- })
148529
+ getAllCodeActions: (context) => codeFixAll(
148530
+ context,
148531
+ errorCodes15,
148532
+ (changes, diag2) => {
148533
+ const newLineCharacter = getNewLineOrDefaultFromHost(context.host, context.formatContext.options);
148534
+ const node = getTokenAtPosition(diag2.file, diag2.start);
148535
+ const fixAll = true;
148536
+ if (node)
148537
+ doChange12(changes, node, diag2.file, newLineCharacter, fixAll);
148538
+ }
148539
+ )
148500
148540
  });
148501
148541
  }
148502
148542
  });
@@ -150771,6 +150811,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
150771
150811
  if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
150772
150812
  return void 0;
150773
150813
  const pos = declaration.parent.arguments.indexOf(declaration);
150814
+ if (pos === -1)
150815
+ return void 0;
150774
150816
  const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
150775
150817
  if (!type)
150776
150818
  return void 0;
@@ -156019,7 +156061,7 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
156019
156061
  getFixes: () => getFixes,
156020
156062
  getImportCompletionAction: () => getImportCompletionAction,
156021
156063
  getImportKind: () => getImportKind,
156022
- getJSDocTypedefNode: () => getJSDocTypedefNode,
156064
+ getJSDocTypedefNodes: () => getJSDocTypedefNodes,
156023
156065
  getNoopSymbolTrackerWithResolver: () => getNoopSymbolTrackerWithResolver,
156024
156066
  getPromoteTypeOnlyCompletionAction: () => getPromoteTypeOnlyCompletionAction,
156025
156067
  getSupportedErrorCodes: () => getSupportedErrorCodes,
@@ -54,7 +54,7 @@ var path = __toESM(require("path"));
54
54
 
55
55
  // src/compiler/corePublic.ts
56
56
  var versionMajorMinor = "5.2";
57
- var version = `${versionMajorMinor}.0-dev.20230721`;
57
+ var version = `${versionMajorMinor}.0-dev.20230723`;
58
58
 
59
59
  // src/compiler/core.ts
60
60
  var emptyArray = [];
@@ -25419,7 +25419,7 @@ function getNamedArgRegEx(name) {
25419
25419
  return result;
25420
25420
  }
25421
25421
  var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
25422
- var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
25422
+ var singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
25423
25423
  function extractPragmas(pragmas, range, text) {
25424
25424
  const tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
25425
25425
  if (tripleSlash) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "5.2.0-dev.20230721",
5
+ "version": "5.2.0-dev.20230723",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -113,5 +113,5 @@
113
113
  "node": "20.1.0",
114
114
  "npm": "8.19.4"
115
115
  },
116
- "gitHead": "61bf78f3c2c8fd4d92e9c56109519edc2e38185f"
116
+ "gitHead": "01b18215eccec4e3b32743ab545bf8c6b570d782"
117
117
  }