typescript 4.8.0-dev.20220610 → 4.8.0-dev.20220611

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
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220610";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220611";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -2239,7 +2239,7 @@ var ts;
2239
2239
  return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2240
2240
  }
2241
2241
  if (isFlags) {
2242
- var result = "";
2242
+ var result = [];
2243
2243
  var remainingFlags = value;
2244
2244
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2245
2245
  var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
@@ -2247,12 +2247,12 @@ var ts;
2247
2247
  break;
2248
2248
  }
2249
2249
  if (enumValue !== 0 && enumValue & value) {
2250
- result = "" + result + (result ? "|" : "") + enumName;
2250
+ result.push(enumName);
2251
2251
  remainingFlags &= ~enumValue;
2252
2252
  }
2253
2253
  }
2254
2254
  if (remainingFlags === 0) {
2255
- return result;
2255
+ return result.join("|");
2256
2256
  }
2257
2257
  }
2258
2258
  else {
@@ -2266,7 +2266,12 @@ var ts;
2266
2266
  return value.toString();
2267
2267
  }
2268
2268
  Debug.formatEnum = formatEnum;
2269
+ var enumMemberCache = new ts.Map();
2269
2270
  function getEnumMembers(enumObject) {
2271
+ var existing = enumMemberCache.get(enumObject);
2272
+ if (existing) {
2273
+ return existing;
2274
+ }
2270
2275
  var result = [];
2271
2276
  for (var name in enumObject) {
2272
2277
  var value = enumObject[name];
@@ -2274,7 +2279,9 @@ var ts;
2274
2279
  result.push([value, name]);
2275
2280
  }
2276
2281
  }
2277
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2282
+ var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2283
+ enumMemberCache.set(enumObject, sorted);
2284
+ return sorted;
2278
2285
  }
2279
2286
  function formatSyntaxKind(kind) {
2280
2287
  return formatEnum(kind, ts.SyntaxKind, false);
@@ -28780,8 +28787,13 @@ var ts;
28780
28787
  case 14:
28781
28788
  case 15:
28782
28789
  return true;
28790
+ case 29:
28791
+ case 31:
28792
+ case 39:
28793
+ case 40:
28794
+ return false;
28783
28795
  }
28784
- return !isStartOfExpression();
28796
+ return scanner.hasPrecedingLineBreak() || isBinaryOperator() || !isStartOfExpression();
28785
28797
  }
28786
28798
  function parsePrimaryExpression() {
28787
28799
  switch (token()) {
@@ -37008,7 +37020,7 @@ var ts;
37008
37020
  case 317:
37009
37021
  return (ts.isJSDocConstructSignature(node) ? "__new" : "__call");
37010
37022
  case 164:
37011
- ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
37023
+ ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; });
37012
37024
  var functionType = node.parent;
37013
37025
  var index = functionType.parameters.indexOf(node);
37014
37026
  return "arg" + index;
@@ -89001,7 +89013,7 @@ var ts;
89001
89013
  return getTypeAliasDeclarationVisibilityError;
89002
89014
  }
89003
89015
  else {
89004
- return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
89016
+ return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind));
89005
89017
  }
89006
89018
  function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
89007
89019
  if (node.kind === 254 || node.kind === 203) {
@@ -89198,7 +89210,7 @@ var ts;
89198
89210
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
89199
89211
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
89200
89212
  default:
89201
- return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
89213
+ return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind));
89202
89214
  }
89203
89215
  }
89204
89216
  function getTypeParameterConstraintVisibilityError() {
@@ -89902,7 +89914,7 @@ var ts;
89902
89914
  while (ts.length(lateMarkedStatements)) {
89903
89915
  var i = lateMarkedStatements.shift();
89904
89916
  if (!ts.isLateVisibilityPaintedStatement(i)) {
89905
- return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind));
89917
+ return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind));
89906
89918
  }
89907
89919
  var priorNeedsDeclare = needsDeclare;
89908
89920
  needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
@@ -90067,7 +90079,7 @@ var ts;
90067
90079
  return cleanup(input);
90068
90080
  return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
90069
90081
  }
90070
- default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
90082
+ default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind));
90071
90083
  }
90072
90084
  }
90073
90085
  if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
@@ -90354,7 +90366,7 @@ var ts;
90354
90366
  }))));
90355
90367
  }
90356
90368
  }
90357
- return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
90369
+ return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind));
90358
90370
  function cleanup(node) {
90359
90371
  if (isEnclosingDeclaration(input)) {
90360
90372
  enclosingDeclaration = previousEnclosingDeclaration;
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220610";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220611";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -2657,7 +2657,7 @@ var ts;
2657
2657
  return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2658
2658
  }
2659
2659
  if (isFlags) {
2660
- var result = "";
2660
+ var result = [];
2661
2661
  var remainingFlags = value;
2662
2662
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2663
2663
  var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
@@ -2665,12 +2665,12 @@ var ts;
2665
2665
  break;
2666
2666
  }
2667
2667
  if (enumValue !== 0 && enumValue & value) {
2668
- result = "" + result + (result ? "|" : "") + enumName;
2668
+ result.push(enumName);
2669
2669
  remainingFlags &= ~enumValue;
2670
2670
  }
2671
2671
  }
2672
2672
  if (remainingFlags === 0) {
2673
- return result;
2673
+ return result.join("|");
2674
2674
  }
2675
2675
  }
2676
2676
  else {
@@ -2684,7 +2684,15 @@ var ts;
2684
2684
  return value.toString();
2685
2685
  }
2686
2686
  Debug.formatEnum = formatEnum;
2687
+ var enumMemberCache = new ts.Map();
2687
2688
  function getEnumMembers(enumObject) {
2689
+ // Assuming enum objects do not change at runtime, we can cache the enum members list
2690
+ // to reuse later. This saves us from reconstructing this each and every time we call
2691
+ // a formatting function (which can be expensive for large enums like SyntaxKind).
2692
+ var existing = enumMemberCache.get(enumObject);
2693
+ if (existing) {
2694
+ return existing;
2695
+ }
2688
2696
  var result = [];
2689
2697
  for (var name in enumObject) {
2690
2698
  var value = enumObject[name];
@@ -2692,7 +2700,9 @@ var ts;
2692
2700
  result.push([value, name]);
2693
2701
  }
2694
2702
  }
2695
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2703
+ var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2704
+ enumMemberCache.set(enumObject, sorted);
2705
+ return sorted;
2696
2706
  }
2697
2707
  function formatSyntaxKind(kind) {
2698
2708
  return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
@@ -4331,6 +4341,7 @@ var ts;
4331
4341
  SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType";
4332
4342
  SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType";
4333
4343
  SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType";
4344
+ SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4334
4345
  /** @deprecated Use SyntaxKind.JSDoc */
4335
4346
  SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment";
4336
4347
  SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText";
@@ -4405,7 +4416,6 @@ var ts;
4405
4416
  SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode";
4406
4417
  /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
4407
4418
  /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword";
4408
- SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4409
4419
  })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
4410
4420
  var NodeFlags;
4411
4421
  (function (NodeFlags) {
@@ -35783,9 +35793,18 @@ var ts;
35783
35793
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35784
35794
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35785
35795
  return true;
35796
+ // A type argument list followed by `<` never makes sense, and a type argument list followed
35797
+ // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in
35798
+ // this context, `+` and `-` are unary operators, not binary operators.
35799
+ case 29 /* LessThanToken */:
35800
+ case 31 /* GreaterThanToken */:
35801
+ case 39 /* PlusToken */:
35802
+ case 40 /* MinusToken */:
35803
+ return false;
35786
35804
  }
35787
- // Consider something a type argument list only if the following token can't start an expression.
35788
- return !isStartOfExpression();
35805
+ // We favor the type argument list interpretation when it is immediately followed by
35806
+ // a line break, a binary operator, or something that can't start an expression.
35807
+ return scanner.hasPrecedingLineBreak() || isBinaryOperator() || !isStartOfExpression();
35789
35808
  }
35790
35809
  function parsePrimaryExpression() {
35791
35810
  switch (token()) {
@@ -45186,7 +45205,7 @@ var ts;
45186
45205
  case 164 /* Parameter */:
45187
45206
  // Parameters with names are handled at the top of this function. Parameters
45188
45207
  // without names can only come from JSDocFunctionTypes.
45189
- ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
45208
+ ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; });
45190
45209
  var functionType = node.parent;
45191
45210
  var index = functionType.parameters.indexOf(node);
45192
45211
  return "arg" + index;
@@ -108446,7 +108465,7 @@ var ts;
108446
108465
  return getTypeAliasDeclarationVisibilityError;
108447
108466
  }
108448
108467
  else {
108449
- return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
108468
+ return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind));
108450
108469
  }
108451
108470
  function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
108452
108471
  if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) {
@@ -108657,7 +108676,7 @@ var ts;
108657
108676
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
108658
108677
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
108659
108678
  default:
108660
- return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
108679
+ return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind));
108661
108680
  }
108662
108681
  }
108663
108682
  function getTypeParameterConstraintVisibilityError() {
@@ -109423,7 +109442,7 @@ var ts;
109423
109442
  while (ts.length(lateMarkedStatements)) {
109424
109443
  var i = lateMarkedStatements.shift();
109425
109444
  if (!ts.isLateVisibilityPaintedStatement(i)) {
109426
- return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind));
109445
+ return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind));
109427
109446
  }
109428
109447
  var priorNeedsDeclare = needsDeclare;
109429
109448
  needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
@@ -109606,7 +109625,7 @@ var ts;
109606
109625
  return cleanup(input);
109607
109626
  return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
109608
109627
  }
109609
- default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
109628
+ default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind));
109610
109629
  }
109611
109630
  }
109612
109631
  if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
@@ -109928,7 +109947,7 @@ var ts;
109928
109947
  }
109929
109948
  }
109930
109949
  // Anything left unhandled is an error, so this should be unreachable
109931
- return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
109950
+ return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind));
109932
109951
  function cleanup(node) {
109933
109952
  if (isEnclosingDeclaration(input)) {
109934
109953
  enclosingDeclaration = previousEnclosingDeclaration;
@@ -150057,7 +150076,7 @@ var ts;
150057
150076
  return {
150058
150077
  indentation: indentation,
150059
150078
  prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
150060
- suffix: insertTrailingComma ? "," : ""
150079
+ suffix: insertTrailingComma ? "," : ts.isInterfaceDeclaration(node) && isEmpty ? ";" : ""
150061
150080
  };
150062
150081
  };
150063
150082
  ChangeTracker.prototype.insertNodeAfterComma = function (sourceFile, after, newNode) {
@@ -158655,7 +158674,7 @@ var ts;
158655
158674
  /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
158656
158675
  case 168 /* MethodSignature */:
158657
158676
  return ts.factory.createMethodSignature(modifiers, name,
158658
- /*questionToken*/ undefined, typeParameters, parameters, type);
158677
+ /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type);
158659
158678
  case 256 /* FunctionDeclaration */:
158660
158679
  return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
158661
158680
  default:
@@ -425,6 +425,7 @@ declare namespace ts {
425
425
  JSDocFunctionType = 317,
426
426
  JSDocVariadicType = 318,
427
427
  JSDocNamepathType = 319,
428
+ JSDoc = 320,
428
429
  /** @deprecated Use SyntaxKind.JSDoc */
429
430
  JSDocComment = 320,
430
431
  JSDocText = 321,
@@ -493,7 +494,6 @@ declare namespace ts {
493
494
  LastJSDocNode = 347,
494
495
  FirstJSDocTagNode = 327,
495
496
  LastJSDocTagNode = 347,
496
- JSDoc = 320
497
497
  }
498
498
  export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
499
499
  export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220610";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220611";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2851,7 +2851,7 @@ var ts;
2851
2851
  return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2852
2852
  }
2853
2853
  if (isFlags) {
2854
- var result = "";
2854
+ var result = [];
2855
2855
  var remainingFlags = value;
2856
2856
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2857
2857
  var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
@@ -2859,12 +2859,12 @@ var ts;
2859
2859
  break;
2860
2860
  }
2861
2861
  if (enumValue !== 0 && enumValue & value) {
2862
- result = "" + result + (result ? "|" : "") + enumName;
2862
+ result.push(enumName);
2863
2863
  remainingFlags &= ~enumValue;
2864
2864
  }
2865
2865
  }
2866
2866
  if (remainingFlags === 0) {
2867
- return result;
2867
+ return result.join("|");
2868
2868
  }
2869
2869
  }
2870
2870
  else {
@@ -2878,7 +2878,15 @@ var ts;
2878
2878
  return value.toString();
2879
2879
  }
2880
2880
  Debug.formatEnum = formatEnum;
2881
+ var enumMemberCache = new ts.Map();
2881
2882
  function getEnumMembers(enumObject) {
2883
+ // Assuming enum objects do not change at runtime, we can cache the enum members list
2884
+ // to reuse later. This saves us from reconstructing this each and every time we call
2885
+ // a formatting function (which can be expensive for large enums like SyntaxKind).
2886
+ var existing = enumMemberCache.get(enumObject);
2887
+ if (existing) {
2888
+ return existing;
2889
+ }
2882
2890
  var result = [];
2883
2891
  for (var name in enumObject) {
2884
2892
  var value = enumObject[name];
@@ -2886,7 +2894,9 @@ var ts;
2886
2894
  result.push([value, name]);
2887
2895
  }
2888
2896
  }
2889
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2897
+ var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2898
+ enumMemberCache.set(enumObject, sorted);
2899
+ return sorted;
2890
2900
  }
2891
2901
  function formatSyntaxKind(kind) {
2892
2902
  return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
@@ -4525,6 +4535,7 @@ var ts;
4525
4535
  SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType";
4526
4536
  SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType";
4527
4537
  SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType";
4538
+ SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4528
4539
  /** @deprecated Use SyntaxKind.JSDoc */
4529
4540
  SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment";
4530
4541
  SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText";
@@ -4599,7 +4610,6 @@ var ts;
4599
4610
  SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode";
4600
4611
  /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
4601
4612
  /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword";
4602
- SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4603
4613
  })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
4604
4614
  var NodeFlags;
4605
4615
  (function (NodeFlags) {
@@ -35977,9 +35987,18 @@ var ts;
35977
35987
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35978
35988
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35979
35989
  return true;
35990
+ // A type argument list followed by `<` never makes sense, and a type argument list followed
35991
+ // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in
35992
+ // this context, `+` and `-` are unary operators, not binary operators.
35993
+ case 29 /* LessThanToken */:
35994
+ case 31 /* GreaterThanToken */:
35995
+ case 39 /* PlusToken */:
35996
+ case 40 /* MinusToken */:
35997
+ return false;
35980
35998
  }
35981
- // Consider something a type argument list only if the following token can't start an expression.
35982
- return !isStartOfExpression();
35999
+ // We favor the type argument list interpretation when it is immediately followed by
36000
+ // a line break, a binary operator, or something that can't start an expression.
36001
+ return scanner.hasPrecedingLineBreak() || isBinaryOperator() || !isStartOfExpression();
35983
36002
  }
35984
36003
  function parsePrimaryExpression() {
35985
36004
  switch (token()) {
@@ -45380,7 +45399,7 @@ var ts;
45380
45399
  case 164 /* Parameter */:
45381
45400
  // Parameters with names are handled at the top of this function. Parameters
45382
45401
  // without names can only come from JSDocFunctionTypes.
45383
- ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
45402
+ ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; });
45384
45403
  var functionType = node.parent;
45385
45404
  var index = functionType.parameters.indexOf(node);
45386
45405
  return "arg" + index;
@@ -108640,7 +108659,7 @@ var ts;
108640
108659
  return getTypeAliasDeclarationVisibilityError;
108641
108660
  }
108642
108661
  else {
108643
- return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
108662
+ return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind));
108644
108663
  }
108645
108664
  function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
108646
108665
  if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) {
@@ -108851,7 +108870,7 @@ var ts;
108851
108870
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
108852
108871
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
108853
108872
  default:
108854
- return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
108873
+ return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind));
108855
108874
  }
108856
108875
  }
108857
108876
  function getTypeParameterConstraintVisibilityError() {
@@ -109617,7 +109636,7 @@ var ts;
109617
109636
  while (ts.length(lateMarkedStatements)) {
109618
109637
  var i = lateMarkedStatements.shift();
109619
109638
  if (!ts.isLateVisibilityPaintedStatement(i)) {
109620
- return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind));
109639
+ return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind));
109621
109640
  }
109622
109641
  var priorNeedsDeclare = needsDeclare;
109623
109642
  needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
@@ -109800,7 +109819,7 @@ var ts;
109800
109819
  return cleanup(input);
109801
109820
  return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
109802
109821
  }
109803
- default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
109822
+ default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind));
109804
109823
  }
109805
109824
  }
109806
109825
  if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
@@ -110122,7 +110141,7 @@ var ts;
110122
110141
  }
110123
110142
  }
110124
110143
  // Anything left unhandled is an error, so this should be unreachable
110125
- return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
110144
+ return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind));
110126
110145
  function cleanup(node) {
110127
110146
  if (isEnclosingDeclaration(input)) {
110128
110147
  enclosingDeclaration = previousEnclosingDeclaration;
@@ -150670,7 +150689,7 @@ var ts;
150670
150689
  return {
150671
150690
  indentation: indentation,
150672
150691
  prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
150673
- suffix: insertTrailingComma ? "," : ""
150692
+ suffix: insertTrailingComma ? "," : ts.isInterfaceDeclaration(node) && isEmpty ? ";" : ""
150674
150693
  };
150675
150694
  };
150676
150695
  ChangeTracker.prototype.insertNodeAfterComma = function (sourceFile, after, newNode) {
@@ -159268,7 +159287,7 @@ var ts;
159268
159287
  /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
159269
159288
  case 168 /* MethodSignature */:
159270
159289
  return ts.factory.createMethodSignature(modifiers, name,
159271
- /*questionToken*/ undefined, typeParameters, parameters, type);
159290
+ /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type);
159272
159291
  case 256 /* FunctionDeclaration */:
159273
159292
  return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
159274
159293
  default:
@@ -425,6 +425,7 @@ declare namespace ts {
425
425
  JSDocFunctionType = 317,
426
426
  JSDocVariadicType = 318,
427
427
  JSDocNamepathType = 319,
428
+ JSDoc = 320,
428
429
  /** @deprecated Use SyntaxKind.JSDoc */
429
430
  JSDocComment = 320,
430
431
  JSDocText = 321,
@@ -493,7 +494,6 @@ declare namespace ts {
493
494
  LastJSDocNode = 347,
494
495
  FirstJSDocTagNode = 327,
495
496
  LastJSDocTagNode = 347,
496
- JSDoc = 320
497
497
  }
498
498
  export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
499
499
  export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220610";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220611";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2851,7 +2851,7 @@ var ts;
2851
2851
  return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2852
2852
  }
2853
2853
  if (isFlags) {
2854
- var result = "";
2854
+ var result = [];
2855
2855
  var remainingFlags = value;
2856
2856
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2857
2857
  var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
@@ -2859,12 +2859,12 @@ var ts;
2859
2859
  break;
2860
2860
  }
2861
2861
  if (enumValue !== 0 && enumValue & value) {
2862
- result = "" + result + (result ? "|" : "") + enumName;
2862
+ result.push(enumName);
2863
2863
  remainingFlags &= ~enumValue;
2864
2864
  }
2865
2865
  }
2866
2866
  if (remainingFlags === 0) {
2867
- return result;
2867
+ return result.join("|");
2868
2868
  }
2869
2869
  }
2870
2870
  else {
@@ -2878,7 +2878,15 @@ var ts;
2878
2878
  return value.toString();
2879
2879
  }
2880
2880
  Debug.formatEnum = formatEnum;
2881
+ var enumMemberCache = new ts.Map();
2881
2882
  function getEnumMembers(enumObject) {
2883
+ // Assuming enum objects do not change at runtime, we can cache the enum members list
2884
+ // to reuse later. This saves us from reconstructing this each and every time we call
2885
+ // a formatting function (which can be expensive for large enums like SyntaxKind).
2886
+ var existing = enumMemberCache.get(enumObject);
2887
+ if (existing) {
2888
+ return existing;
2889
+ }
2882
2890
  var result = [];
2883
2891
  for (var name in enumObject) {
2884
2892
  var value = enumObject[name];
@@ -2886,7 +2894,9 @@ var ts;
2886
2894
  result.push([value, name]);
2887
2895
  }
2888
2896
  }
2889
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2897
+ var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2898
+ enumMemberCache.set(enumObject, sorted);
2899
+ return sorted;
2890
2900
  }
2891
2901
  function formatSyntaxKind(kind) {
2892
2902
  return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
@@ -4525,6 +4535,7 @@ var ts;
4525
4535
  SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType";
4526
4536
  SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType";
4527
4537
  SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType";
4538
+ SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4528
4539
  /** @deprecated Use SyntaxKind.JSDoc */
4529
4540
  SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment";
4530
4541
  SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText";
@@ -4599,7 +4610,6 @@ var ts;
4599
4610
  SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode";
4600
4611
  /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
4601
4612
  /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword";
4602
- SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4603
4613
  })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
4604
4614
  var NodeFlags;
4605
4615
  (function (NodeFlags) {
@@ -35977,9 +35987,18 @@ var ts;
35977
35987
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35978
35988
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35979
35989
  return true;
35990
+ // A type argument list followed by `<` never makes sense, and a type argument list followed
35991
+ // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in
35992
+ // this context, `+` and `-` are unary operators, not binary operators.
35993
+ case 29 /* LessThanToken */:
35994
+ case 31 /* GreaterThanToken */:
35995
+ case 39 /* PlusToken */:
35996
+ case 40 /* MinusToken */:
35997
+ return false;
35980
35998
  }
35981
- // Consider something a type argument list only if the following token can't start an expression.
35982
- return !isStartOfExpression();
35999
+ // We favor the type argument list interpretation when it is immediately followed by
36000
+ // a line break, a binary operator, or something that can't start an expression.
36001
+ return scanner.hasPrecedingLineBreak() || isBinaryOperator() || !isStartOfExpression();
35983
36002
  }
35984
36003
  function parsePrimaryExpression() {
35985
36004
  switch (token()) {
@@ -45380,7 +45399,7 @@ var ts;
45380
45399
  case 164 /* Parameter */:
45381
45400
  // Parameters with names are handled at the top of this function. Parameters
45382
45401
  // without names can only come from JSDocFunctionTypes.
45383
- ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
45402
+ ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; });
45384
45403
  var functionType = node.parent;
45385
45404
  var index = functionType.parameters.indexOf(node);
45386
45405
  return "arg" + index;
@@ -108640,7 +108659,7 @@ var ts;
108640
108659
  return getTypeAliasDeclarationVisibilityError;
108641
108660
  }
108642
108661
  else {
108643
- return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
108662
+ return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind));
108644
108663
  }
108645
108664
  function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
108646
108665
  if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) {
@@ -108851,7 +108870,7 @@ var ts;
108851
108870
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
108852
108871
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
108853
108872
  default:
108854
- return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
108873
+ return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind));
108855
108874
  }
108856
108875
  }
108857
108876
  function getTypeParameterConstraintVisibilityError() {
@@ -109617,7 +109636,7 @@ var ts;
109617
109636
  while (ts.length(lateMarkedStatements)) {
109618
109637
  var i = lateMarkedStatements.shift();
109619
109638
  if (!ts.isLateVisibilityPaintedStatement(i)) {
109620
- return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind));
109639
+ return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind));
109621
109640
  }
109622
109641
  var priorNeedsDeclare = needsDeclare;
109623
109642
  needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
@@ -109800,7 +109819,7 @@ var ts;
109800
109819
  return cleanup(input);
109801
109820
  return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
109802
109821
  }
109803
- default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
109822
+ default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind));
109804
109823
  }
109805
109824
  }
109806
109825
  if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
@@ -110122,7 +110141,7 @@ var ts;
110122
110141
  }
110123
110142
  }
110124
110143
  // Anything left unhandled is an error, so this should be unreachable
110125
- return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
110144
+ return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind));
110126
110145
  function cleanup(node) {
110127
110146
  if (isEnclosingDeclaration(input)) {
110128
110147
  enclosingDeclaration = previousEnclosingDeclaration;
@@ -150670,7 +150689,7 @@ var ts;
150670
150689
  return {
150671
150690
  indentation: indentation,
150672
150691
  prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
150673
- suffix: insertTrailingComma ? "," : ""
150692
+ suffix: insertTrailingComma ? "," : ts.isInterfaceDeclaration(node) && isEmpty ? ";" : ""
150674
150693
  };
150675
150694
  };
150676
150695
  ChangeTracker.prototype.insertNodeAfterComma = function (sourceFile, after, newNode) {
@@ -159268,7 +159287,7 @@ var ts;
159268
159287
  /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
159269
159288
  case 168 /* MethodSignature */:
159270
159289
  return ts.factory.createMethodSignature(modifiers, name,
159271
- /*questionToken*/ undefined, typeParameters, parameters, type);
159290
+ /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type);
159272
159291
  case 256 /* FunctionDeclaration */:
159273
159292
  return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
159274
159293
  default:
@@ -425,6 +425,7 @@ declare namespace ts {
425
425
  JSDocFunctionType = 317,
426
426
  JSDocVariadicType = 318,
427
427
  JSDocNamepathType = 319,
428
+ JSDoc = 320,
428
429
  /** @deprecated Use SyntaxKind.JSDoc */
429
430
  JSDocComment = 320,
430
431
  JSDocText = 321,
@@ -493,7 +494,6 @@ declare namespace ts {
493
494
  LastJSDocNode = 347,
494
495
  FirstJSDocTagNode = 327,
495
496
  LastJSDocTagNode = 347,
496
- JSDoc = 320
497
497
  }
498
498
  export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
499
499
  export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220610";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220611";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2851,7 +2851,7 @@ var ts;
2851
2851
  return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2852
2852
  }
2853
2853
  if (isFlags) {
2854
- var result = "";
2854
+ var result = [];
2855
2855
  var remainingFlags = value;
2856
2856
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2857
2857
  var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
@@ -2859,12 +2859,12 @@ var ts;
2859
2859
  break;
2860
2860
  }
2861
2861
  if (enumValue !== 0 && enumValue & value) {
2862
- result = "" + result + (result ? "|" : "") + enumName;
2862
+ result.push(enumName);
2863
2863
  remainingFlags &= ~enumValue;
2864
2864
  }
2865
2865
  }
2866
2866
  if (remainingFlags === 0) {
2867
- return result;
2867
+ return result.join("|");
2868
2868
  }
2869
2869
  }
2870
2870
  else {
@@ -2878,7 +2878,15 @@ var ts;
2878
2878
  return value.toString();
2879
2879
  }
2880
2880
  Debug.formatEnum = formatEnum;
2881
+ var enumMemberCache = new ts.Map();
2881
2882
  function getEnumMembers(enumObject) {
2883
+ // Assuming enum objects do not change at runtime, we can cache the enum members list
2884
+ // to reuse later. This saves us from reconstructing this each and every time we call
2885
+ // a formatting function (which can be expensive for large enums like SyntaxKind).
2886
+ var existing = enumMemberCache.get(enumObject);
2887
+ if (existing) {
2888
+ return existing;
2889
+ }
2882
2890
  var result = [];
2883
2891
  for (var name in enumObject) {
2884
2892
  var value = enumObject[name];
@@ -2886,7 +2894,9 @@ var ts;
2886
2894
  result.push([value, name]);
2887
2895
  }
2888
2896
  }
2889
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2897
+ var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2898
+ enumMemberCache.set(enumObject, sorted);
2899
+ return sorted;
2890
2900
  }
2891
2901
  function formatSyntaxKind(kind) {
2892
2902
  return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
@@ -4525,6 +4535,7 @@ var ts;
4525
4535
  SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType";
4526
4536
  SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType";
4527
4537
  SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType";
4538
+ SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4528
4539
  /** @deprecated Use SyntaxKind.JSDoc */
4529
4540
  SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment";
4530
4541
  SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText";
@@ -4599,7 +4610,6 @@ var ts;
4599
4610
  SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode";
4600
4611
  /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
4601
4612
  /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword";
4602
- SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4603
4613
  })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
4604
4614
  var NodeFlags;
4605
4615
  (function (NodeFlags) {
@@ -35977,9 +35987,18 @@ var ts;
35977
35987
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35978
35988
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35979
35989
  return true;
35990
+ // A type argument list followed by `<` never makes sense, and a type argument list followed
35991
+ // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in
35992
+ // this context, `+` and `-` are unary operators, not binary operators.
35993
+ case 29 /* LessThanToken */:
35994
+ case 31 /* GreaterThanToken */:
35995
+ case 39 /* PlusToken */:
35996
+ case 40 /* MinusToken */:
35997
+ return false;
35980
35998
  }
35981
- // Consider something a type argument list only if the following token can't start an expression.
35982
- return !isStartOfExpression();
35999
+ // We favor the type argument list interpretation when it is immediately followed by
36000
+ // a line break, a binary operator, or something that can't start an expression.
36001
+ return scanner.hasPrecedingLineBreak() || isBinaryOperator() || !isStartOfExpression();
35983
36002
  }
35984
36003
  function parsePrimaryExpression() {
35985
36004
  switch (token()) {
@@ -45380,7 +45399,7 @@ var ts;
45380
45399
  case 164 /* Parameter */:
45381
45400
  // Parameters with names are handled at the top of this function. Parameters
45382
45401
  // without names can only come from JSDocFunctionTypes.
45383
- ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
45402
+ ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; });
45384
45403
  var functionType = node.parent;
45385
45404
  var index = functionType.parameters.indexOf(node);
45386
45405
  return "arg" + index;
@@ -108640,7 +108659,7 @@ var ts;
108640
108659
  return getTypeAliasDeclarationVisibilityError;
108641
108660
  }
108642
108661
  else {
108643
- return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
108662
+ return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind));
108644
108663
  }
108645
108664
  function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
108646
108665
  if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) {
@@ -108851,7 +108870,7 @@ var ts;
108851
108870
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
108852
108871
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
108853
108872
  default:
108854
- return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
108873
+ return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind));
108855
108874
  }
108856
108875
  }
108857
108876
  function getTypeParameterConstraintVisibilityError() {
@@ -109617,7 +109636,7 @@ var ts;
109617
109636
  while (ts.length(lateMarkedStatements)) {
109618
109637
  var i = lateMarkedStatements.shift();
109619
109638
  if (!ts.isLateVisibilityPaintedStatement(i)) {
109620
- return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind));
109639
+ return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind));
109621
109640
  }
109622
109641
  var priorNeedsDeclare = needsDeclare;
109623
109642
  needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
@@ -109800,7 +109819,7 @@ var ts;
109800
109819
  return cleanup(input);
109801
109820
  return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
109802
109821
  }
109803
- default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
109822
+ default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind));
109804
109823
  }
109805
109824
  }
109806
109825
  if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
@@ -110122,7 +110141,7 @@ var ts;
110122
110141
  }
110123
110142
  }
110124
110143
  // Anything left unhandled is an error, so this should be unreachable
110125
- return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
110144
+ return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind));
110126
110145
  function cleanup(node) {
110127
110146
  if (isEnclosingDeclaration(input)) {
110128
110147
  enclosingDeclaration = previousEnclosingDeclaration;
@@ -150670,7 +150689,7 @@ var ts;
150670
150689
  return {
150671
150690
  indentation: indentation,
150672
150691
  prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
150673
- suffix: insertTrailingComma ? "," : ""
150692
+ suffix: insertTrailingComma ? "," : ts.isInterfaceDeclaration(node) && isEmpty ? ";" : ""
150674
150693
  };
150675
150694
  };
150676
150695
  ChangeTracker.prototype.insertNodeAfterComma = function (sourceFile, after, newNode) {
@@ -159268,7 +159287,7 @@ var ts;
159268
159287
  /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
159269
159288
  case 168 /* MethodSignature */:
159270
159289
  return ts.factory.createMethodSignature(modifiers, name,
159271
- /*questionToken*/ undefined, typeParameters, parameters, type);
159290
+ /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type);
159272
159291
  case 256 /* FunctionDeclaration */:
159273
159292
  return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
159274
159293
  default:
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220610";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220611";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -2646,7 +2646,7 @@ var ts;
2646
2646
  return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2647
2647
  }
2648
2648
  if (isFlags) {
2649
- var result = "";
2649
+ var result = [];
2650
2650
  var remainingFlags = value;
2651
2651
  for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2652
2652
  var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
@@ -2654,12 +2654,12 @@ var ts;
2654
2654
  break;
2655
2655
  }
2656
2656
  if (enumValue !== 0 && enumValue & value) {
2657
- result = "" + result + (result ? "|" : "") + enumName;
2657
+ result.push(enumName);
2658
2658
  remainingFlags &= ~enumValue;
2659
2659
  }
2660
2660
  }
2661
2661
  if (remainingFlags === 0) {
2662
- return result;
2662
+ return result.join("|");
2663
2663
  }
2664
2664
  }
2665
2665
  else {
@@ -2673,7 +2673,15 @@ var ts;
2673
2673
  return value.toString();
2674
2674
  }
2675
2675
  Debug.formatEnum = formatEnum;
2676
+ var enumMemberCache = new ts.Map();
2676
2677
  function getEnumMembers(enumObject) {
2678
+ // Assuming enum objects do not change at runtime, we can cache the enum members list
2679
+ // to reuse later. This saves us from reconstructing this each and every time we call
2680
+ // a formatting function (which can be expensive for large enums like SyntaxKind).
2681
+ var existing = enumMemberCache.get(enumObject);
2682
+ if (existing) {
2683
+ return existing;
2684
+ }
2677
2685
  var result = [];
2678
2686
  for (var name in enumObject) {
2679
2687
  var value = enumObject[name];
@@ -2681,7 +2689,9 @@ var ts;
2681
2689
  result.push([value, name]);
2682
2690
  }
2683
2691
  }
2684
- return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2692
+ var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2693
+ enumMemberCache.set(enumObject, sorted);
2694
+ return sorted;
2685
2695
  }
2686
2696
  function formatSyntaxKind(kind) {
2687
2697
  return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
@@ -4320,6 +4330,7 @@ var ts;
4320
4330
  SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType";
4321
4331
  SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType";
4322
4332
  SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType";
4333
+ SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4323
4334
  /** @deprecated Use SyntaxKind.JSDoc */
4324
4335
  SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment";
4325
4336
  SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText";
@@ -4394,7 +4405,6 @@ var ts;
4394
4405
  SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode";
4395
4406
  /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
4396
4407
  /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword";
4397
- SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
4398
4408
  })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
4399
4409
  var NodeFlags;
4400
4410
  (function (NodeFlags) {
@@ -35772,9 +35782,18 @@ var ts;
35772
35782
  case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
35773
35783
  case 15 /* TemplateHead */: // foo<T> `...${100}...`
35774
35784
  return true;
35785
+ // A type argument list followed by `<` never makes sense, and a type argument list followed
35786
+ // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in
35787
+ // this context, `+` and `-` are unary operators, not binary operators.
35788
+ case 29 /* LessThanToken */:
35789
+ case 31 /* GreaterThanToken */:
35790
+ case 39 /* PlusToken */:
35791
+ case 40 /* MinusToken */:
35792
+ return false;
35775
35793
  }
35776
- // Consider something a type argument list only if the following token can't start an expression.
35777
- return !isStartOfExpression();
35794
+ // We favor the type argument list interpretation when it is immediately followed by
35795
+ // a line break, a binary operator, or something that can't start an expression.
35796
+ return scanner.hasPrecedingLineBreak() || isBinaryOperator() || !isStartOfExpression();
35778
35797
  }
35779
35798
  function parsePrimaryExpression() {
35780
35799
  switch (token()) {
@@ -45175,7 +45194,7 @@ var ts;
45175
45194
  case 164 /* Parameter */:
45176
45195
  // Parameters with names are handled at the top of this function. Parameters
45177
45196
  // without names can only come from JSDocFunctionTypes.
45178
- ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; });
45197
+ ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; });
45179
45198
  var functionType = node.parent;
45180
45199
  var index = functionType.parameters.indexOf(node);
45181
45200
  return "arg" + index;
@@ -108435,7 +108454,7 @@ var ts;
108435
108454
  return getTypeAliasDeclarationVisibilityError;
108436
108455
  }
108437
108456
  else {
108438
- return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
108457
+ return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind));
108439
108458
  }
108440
108459
  function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
108441
108460
  if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) {
@@ -108646,7 +108665,7 @@ var ts;
108646
108665
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
108647
108666
  ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
108648
108667
  default:
108649
- return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
108668
+ return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind));
108650
108669
  }
108651
108670
  }
108652
108671
  function getTypeParameterConstraintVisibilityError() {
@@ -109412,7 +109431,7 @@ var ts;
109412
109431
  while (ts.length(lateMarkedStatements)) {
109413
109432
  var i = lateMarkedStatements.shift();
109414
109433
  if (!ts.isLateVisibilityPaintedStatement(i)) {
109415
- return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + (ts.SyntaxKind ? ts.SyntaxKind[i.kind] : i.kind));
109434
+ return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind));
109416
109435
  }
109417
109436
  var priorNeedsDeclare = needsDeclare;
109418
109437
  needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
@@ -109595,7 +109614,7 @@ var ts;
109595
109614
  return cleanup(input);
109596
109615
  return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
109597
109616
  }
109598
- default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
109617
+ default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind));
109599
109618
  }
109600
109619
  }
109601
109620
  if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
@@ -109917,7 +109936,7 @@ var ts;
109917
109936
  }
109918
109937
  }
109919
109938
  // Anything left unhandled is an error, so this should be unreachable
109920
- return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
109939
+ return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind));
109921
109940
  function cleanup(node) {
109922
109941
  if (isEnclosingDeclaration(input)) {
109923
109942
  enclosingDeclaration = previousEnclosingDeclaration;
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": "4.8.0-dev.20220610",
5
+ "version": "4.8.0-dev.20220611",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [