typescript 5.6.0-dev.20240814 → 5.6.0-dev.20240815

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.6";
21
- var version = `${versionMajorMinor}.0-dev.20240814`;
21
+ var version = `${versionMajorMinor}.0-dev.20240815`;
22
22
 
23
23
  // src/compiler/core.ts
24
24
  var emptyArray = [];
@@ -7390,6 +7390,7 @@ var Diagnostics = {
7390
7390
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
7391
7391
  Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported: diag(6805, 3 /* Message */, "Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported_6805", "Disable full type checking (only critical parse and emit errors will be reported)."),
7392
7392
  Check_side_effect_imports: diag(6806, 3 /* Message */, "Check_side_effect_imports_6806", "Check side effect imports."),
7393
+ This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2: diag(6807, 1 /* Error */, "This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2_6807", "This operation can be simplified. This shift is identical to `{0} {1} {2}`."),
7393
7394
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
7394
7395
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
7395
7396
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -44067,21 +44068,25 @@ function createBinder() {
44067
44068
  const reportError = (
44068
44069
  // report error on all statements except empty ones
44069
44070
  isStatementButNotDeclaration(node) && node.kind !== 242 /* EmptyStatement */ || // report error on class declarations
44070
- node.kind === 263 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
44071
+ node.kind === 263 /* ClassDeclaration */ || // report errors on enums with preserved emit
44072
+ isEnumDeclarationWithPreservedEmit(node, options) || // report error on instantiated modules
44071
44073
  node.kind === 267 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
44072
44074
  );
44073
44075
  if (reportError) {
44074
44076
  currentFlow = reportedUnreachableFlow;
44075
44077
  if (!options.allowUnreachableCode) {
44076
44078
  const isError = unreachableCodeIsError(options) && !(node.flags & 33554432 /* Ambient */) && (!isVariableStatement(node) || !!(getCombinedNodeFlags(node.declarationList) & 7 /* BlockScoped */) || node.declarationList.declarations.some((d) => !!d.initializer));
44077
- eachUnreachableRange(node, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
44079
+ eachUnreachableRange(node, options, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
44078
44080
  }
44079
44081
  }
44080
44082
  }
44081
44083
  return true;
44082
44084
  }
44083
44085
  }
44084
- function eachUnreachableRange(node, cb) {
44086
+ function isEnumDeclarationWithPreservedEmit(node, options) {
44087
+ return node.kind === 266 /* EnumDeclaration */ && (!isEnumConst(node) || shouldPreserveConstEnums(options));
44088
+ }
44089
+ function eachUnreachableRange(node, options, cb) {
44085
44090
  if (isStatement(node) && isExecutableStatement(node) && isBlock(node.parent)) {
44086
44091
  const { statements } = node.parent;
44087
44092
  const slice = sliceAfter(statements, node);
@@ -44089,22 +44094,22 @@ function eachUnreachableRange(node, cb) {
44089
44094
  } else {
44090
44095
  cb(node, node);
44091
44096
  }
44092
- }
44093
- function isExecutableStatement(s) {
44094
- return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !isEnumDeclaration(s) && // `var x;` may declare a variable used above
44095
- !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & 7 /* BlockScoped */) && s.declarationList.declarations.some((d) => !d.initializer));
44096
- }
44097
- function isPurelyTypeDeclaration(s) {
44098
- switch (s.kind) {
44099
- case 264 /* InterfaceDeclaration */:
44100
- case 265 /* TypeAliasDeclaration */:
44101
- return true;
44102
- case 267 /* ModuleDeclaration */:
44103
- return getModuleInstanceState(s) !== 1 /* Instantiated */;
44104
- case 266 /* EnumDeclaration */:
44105
- return hasSyntacticModifier(s, 4096 /* Const */);
44106
- default:
44107
- return false;
44097
+ function isExecutableStatement(s) {
44098
+ return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && // `var x;` may declare a variable used above
44099
+ !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & 7 /* BlockScoped */) && s.declarationList.declarations.some((d) => !d.initializer));
44100
+ }
44101
+ function isPurelyTypeDeclaration(s) {
44102
+ switch (s.kind) {
44103
+ case 264 /* InterfaceDeclaration */:
44104
+ case 265 /* TypeAliasDeclaration */:
44105
+ return true;
44106
+ case 267 /* ModuleDeclaration */:
44107
+ return getModuleInstanceState(s) !== 1 /* Instantiated */;
44108
+ case 266 /* EnumDeclaration */:
44109
+ return !isEnumDeclarationWithPreservedEmit(s, options);
44110
+ default:
44111
+ return false;
44112
+ }
44108
44113
  }
44109
44114
  }
44110
44115
  function isExportsOrModuleExportsOrAlias(sourceFile, node) {
@@ -60239,7 +60244,7 @@ function createTypeChecker(host) {
60239
60244
  } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
60240
60245
  removeFromEach(typeSet, 65536 /* Null */);
60241
60246
  result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
60242
- } else if (typeSet.length >= 4) {
60247
+ } else if (typeSet.length >= 3 && types.length > 2) {
60243
60248
  const middle = Math.floor(typeSet.length / 2);
60244
60249
  result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle), flags), getIntersectionType(typeSet.slice(middle), flags)], flags, aliasSymbol, aliasTypeArguments);
60245
60250
  } else {
@@ -78136,6 +78141,29 @@ function createTypeChecker(host) {
78136
78141
  }
78137
78142
  if (leftOk && rightOk) {
78138
78143
  checkAssignmentOperator(resultType2);
78144
+ switch (operator) {
78145
+ case 48 /* LessThanLessThanToken */:
78146
+ case 71 /* LessThanLessThanEqualsToken */:
78147
+ case 49 /* GreaterThanGreaterThanToken */:
78148
+ case 72 /* GreaterThanGreaterThanEqualsToken */:
78149
+ case 50 /* GreaterThanGreaterThanGreaterThanToken */:
78150
+ case 73 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
78151
+ const rhsEval = evaluate(right);
78152
+ if (typeof rhsEval.value === "number" && Math.abs(rhsEval.value) >= 32) {
78153
+ errorOrSuggestion(
78154
+ isEnumMember(walkUpParenthesizedExpressions(right.parent.parent)),
78155
+ // elevate from suggestion to error within an enum member
78156
+ errorNode || operatorToken,
78157
+ Diagnostics.This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2,
78158
+ getTextOfNode(left),
78159
+ tokenToString(operator),
78160
+ rhsEval.value % 32
78161
+ );
78162
+ }
78163
+ break;
78164
+ default:
78165
+ break;
78166
+ }
78139
78167
  }
78140
78168
  return resultType2;
78141
78169
  }
package/lib/typescript.js CHANGED
@@ -2262,7 +2262,7 @@ module.exports = __toCommonJS(typescript_exports);
2262
2262
 
2263
2263
  // src/compiler/corePublic.ts
2264
2264
  var versionMajorMinor = "5.6";
2265
- var version = `${versionMajorMinor}.0-dev.20240814`;
2265
+ var version = `${versionMajorMinor}.0-dev.20240815`;
2266
2266
  var Comparison = /* @__PURE__ */ ((Comparison3) => {
2267
2267
  Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
2268
2268
  Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
@@ -10787,6 +10787,7 @@ var Diagnostics = {
10787
10787
  Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_in_the_output_file_s_format_based_on_the_module_setting: diag(6804, 3 /* Message */, "Do_not_transform_or_elide_any_imports_or_exports_not_marked_as_type_only_ensuring_they_are_written_i_6804", "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."),
10788
10788
  Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported: diag(6805, 3 /* Message */, "Disable_full_type_checking_only_critical_parse_and_emit_errors_will_be_reported_6805", "Disable full type checking (only critical parse and emit errors will be reported)."),
10789
10789
  Check_side_effect_imports: diag(6806, 3 /* Message */, "Check_side_effect_imports_6806", "Check side effect imports."),
10790
+ This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2: diag(6807, 1 /* Error */, "This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2_6807", "This operation can be simplified. This shift is identical to `{0} {1} {2}`."),
10790
10791
  one_of_Colon: diag(6900, 3 /* Message */, "one_of_Colon_6900", "one of:"),
10791
10792
  one_or_more_Colon: diag(6901, 3 /* Message */, "one_or_more_Colon_6901", "one or more:"),
10792
10793
  type_Colon: diag(6902, 3 /* Message */, "type_Colon_6902", "type:"),
@@ -48586,21 +48587,25 @@ function createBinder() {
48586
48587
  const reportError = (
48587
48588
  // report error on all statements except empty ones
48588
48589
  isStatementButNotDeclaration(node) && node.kind !== 242 /* EmptyStatement */ || // report error on class declarations
48589
- node.kind === 263 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
48590
+ node.kind === 263 /* ClassDeclaration */ || // report errors on enums with preserved emit
48591
+ isEnumDeclarationWithPreservedEmit(node, options) || // report error on instantiated modules
48590
48592
  node.kind === 267 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
48591
48593
  );
48592
48594
  if (reportError) {
48593
48595
  currentFlow = reportedUnreachableFlow;
48594
48596
  if (!options.allowUnreachableCode) {
48595
48597
  const isError = unreachableCodeIsError(options) && !(node.flags & 33554432 /* Ambient */) && (!isVariableStatement(node) || !!(getCombinedNodeFlags(node.declarationList) & 7 /* BlockScoped */) || node.declarationList.declarations.some((d) => !!d.initializer));
48596
- eachUnreachableRange(node, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
48598
+ eachUnreachableRange(node, options, (start, end) => errorOrSuggestionOnRange(isError, start, end, Diagnostics.Unreachable_code_detected));
48597
48599
  }
48598
48600
  }
48599
48601
  }
48600
48602
  return true;
48601
48603
  }
48602
48604
  }
48603
- function eachUnreachableRange(node, cb) {
48605
+ function isEnumDeclarationWithPreservedEmit(node, options) {
48606
+ return node.kind === 266 /* EnumDeclaration */ && (!isEnumConst(node) || shouldPreserveConstEnums(options));
48607
+ }
48608
+ function eachUnreachableRange(node, options, cb) {
48604
48609
  if (isStatement(node) && isExecutableStatement(node) && isBlock(node.parent)) {
48605
48610
  const { statements } = node.parent;
48606
48611
  const slice = sliceAfter(statements, node);
@@ -48608,22 +48613,22 @@ function eachUnreachableRange(node, cb) {
48608
48613
  } else {
48609
48614
  cb(node, node);
48610
48615
  }
48611
- }
48612
- function isExecutableStatement(s) {
48613
- return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !isEnumDeclaration(s) && // `var x;` may declare a variable used above
48614
- !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & 7 /* BlockScoped */) && s.declarationList.declarations.some((d) => !d.initializer));
48615
- }
48616
- function isPurelyTypeDeclaration(s) {
48617
- switch (s.kind) {
48618
- case 264 /* InterfaceDeclaration */:
48619
- case 265 /* TypeAliasDeclaration */:
48620
- return true;
48621
- case 267 /* ModuleDeclaration */:
48622
- return getModuleInstanceState(s) !== 1 /* Instantiated */;
48623
- case 266 /* EnumDeclaration */:
48624
- return hasSyntacticModifier(s, 4096 /* Const */);
48625
- default:
48626
- return false;
48616
+ function isExecutableStatement(s) {
48617
+ return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && // `var x;` may declare a variable used above
48618
+ !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & 7 /* BlockScoped */) && s.declarationList.declarations.some((d) => !d.initializer));
48619
+ }
48620
+ function isPurelyTypeDeclaration(s) {
48621
+ switch (s.kind) {
48622
+ case 264 /* InterfaceDeclaration */:
48623
+ case 265 /* TypeAliasDeclaration */:
48624
+ return true;
48625
+ case 267 /* ModuleDeclaration */:
48626
+ return getModuleInstanceState(s) !== 1 /* Instantiated */;
48627
+ case 266 /* EnumDeclaration */:
48628
+ return !isEnumDeclarationWithPreservedEmit(s, options);
48629
+ default:
48630
+ return false;
48631
+ }
48627
48632
  }
48628
48633
  }
48629
48634
  function isExportsOrModuleExportsOrAlias(sourceFile, node) {
@@ -64858,7 +64863,7 @@ function createTypeChecker(host) {
64858
64863
  } else if (every(typeSet, (t) => !!(t.flags & 1048576 /* Union */ && (t.types[0].flags & 65536 /* Null */ || t.types[1].flags & 65536 /* Null */)))) {
64859
64864
  removeFromEach(typeSet, 65536 /* Null */);
64860
64865
  result = getUnionType([getIntersectionType(typeSet, flags), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments);
64861
- } else if (typeSet.length >= 4) {
64866
+ } else if (typeSet.length >= 3 && types.length > 2) {
64862
64867
  const middle = Math.floor(typeSet.length / 2);
64863
64868
  result = getIntersectionType([getIntersectionType(typeSet.slice(0, middle), flags), getIntersectionType(typeSet.slice(middle), flags)], flags, aliasSymbol, aliasTypeArguments);
64864
64869
  } else {
@@ -82755,6 +82760,29 @@ function createTypeChecker(host) {
82755
82760
  }
82756
82761
  if (leftOk && rightOk) {
82757
82762
  checkAssignmentOperator(resultType2);
82763
+ switch (operator) {
82764
+ case 48 /* LessThanLessThanToken */:
82765
+ case 71 /* LessThanLessThanEqualsToken */:
82766
+ case 49 /* GreaterThanGreaterThanToken */:
82767
+ case 72 /* GreaterThanGreaterThanEqualsToken */:
82768
+ case 50 /* GreaterThanGreaterThanGreaterThanToken */:
82769
+ case 73 /* GreaterThanGreaterThanGreaterThanEqualsToken */:
82770
+ const rhsEval = evaluate(right);
82771
+ if (typeof rhsEval.value === "number" && Math.abs(rhsEval.value) >= 32) {
82772
+ errorOrSuggestion(
82773
+ isEnumMember(walkUpParenthesizedExpressions(right.parent.parent)),
82774
+ // elevate from suggestion to error within an enum member
82775
+ errorNode || operatorToken,
82776
+ Diagnostics.This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2,
82777
+ getTextOfNode(left),
82778
+ tokenToString(operator),
82779
+ rhsEval.value % 32
82780
+ );
82781
+ }
82782
+ break;
82783
+ default:
82784
+ break;
82785
+ }
82758
82786
  }
82759
82787
  return resultType2;
82760
82788
  }
@@ -142063,7 +142091,8 @@ function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
142063
142091
  }
142064
142092
  addRange(diags, sourceFile.bindSuggestionDiagnostics);
142065
142093
  addRange(diags, program.getSuggestionDiagnostics(sourceFile, cancellationToken));
142066
- return diags.sort((d1, d2) => d1.start - d2.start);
142094
+ diags.sort((d1, d2) => d1.start - d2.start);
142095
+ return diags;
142067
142096
  function check(node) {
142068
142097
  if (isJsFile) {
142069
142098
  if (canBeConvertedToClass(node, checker)) {
@@ -142504,7 +142533,8 @@ function getContainers(declaration) {
142504
142533
  }
142505
142534
  container = getContainerNode(container);
142506
142535
  }
142507
- return containers.reverse();
142536
+ containers.reverse();
142537
+ return containers;
142508
142538
  }
142509
142539
  function compareNavigateToItems(i1, i2) {
142510
142540
  return compareValues(i1.matchKind, i2.matchKind) || compareStringsCaseSensitiveUI(i1.name, i2.name);
@@ -147404,8 +147434,8 @@ function extractFunctionInScope(node, scope, { usages: usagesInScope, typeParame
147404
147434
  callArguments.push(factory.createIdentifier(name));
147405
147435
  });
147406
147436
  const typeParametersAndDeclarations = arrayFrom(typeParameterUsages.values(), (type) => ({ type, declaration: getFirstDeclarationBeforePosition(type, context.startPosition) }));
147407
- const sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder);
147408
- const typeParameters = sortedTypeParametersAndDeclarations.length === 0 ? void 0 : mapDefined(sortedTypeParametersAndDeclarations, ({ declaration }) => declaration);
147437
+ typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder);
147438
+ const typeParameters = typeParametersAndDeclarations.length === 0 ? void 0 : mapDefined(typeParametersAndDeclarations, ({ declaration }) => declaration);
147409
147439
  const callTypeArguments = typeParameters !== void 0 ? typeParameters.map((decl) => factory.createTypeReferenceNode(
147410
147440
  decl.name,
147411
147441
  /*typeArguments*/
@@ -172494,9 +172524,10 @@ ${content}
172494
172524
  parsedNodes.push({ sourceFile: sourceFile2, body: bod });
172495
172525
  }
172496
172526
  }
172497
- const { body } = parsedNodes.sort(
172527
+ parsedNodes.sort(
172498
172528
  (a, b) => a.sourceFile.parseDiagnostics.length - b.sourceFile.parseDiagnostics.length
172499
- )[0];
172529
+ );
172530
+ const { body } = parsedNodes[0];
172500
172531
  return body;
172501
172532
  }
172502
172533
  function placeNodeGroup(originalFile, changeTracker, changes, focusLocations) {
@@ -173307,7 +173338,8 @@ function collectElements(sourceFile, cancellationToken) {
173307
173338
  const res = [];
173308
173339
  addNodeOutliningSpans(sourceFile, cancellationToken, res);
173309
173340
  addRegionOutliningSpans(sourceFile, res);
173310
- return res.sort((span1, span2) => span1.textSpan.start - span2.textSpan.start);
173341
+ res.sort((span1, span2) => span1.textSpan.start - span2.textSpan.start);
173342
+ return res;
173311
173343
  }
173312
173344
  function addNodeOutliningSpans(sourceFile, cancellationToken, out) {
173313
173345
  let depthRemaining = 40;
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.6.0-dev.20240814",
5
+ "version": "5.6.0-dev.20240815",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -53,6 +53,7 @@
53
53
  "@types/source-map-support": "^0.5.10",
54
54
  "@types/which": "^3.0.4",
55
55
  "@typescript-eslint/rule-tester": "^8.1.0",
56
+ "@typescript-eslint/type-utils": "^8.1.0",
56
57
  "@typescript-eslint/utils": "^8.1.0",
57
58
  "azure-devops-node-api": "^14.0.2",
58
59
  "c8": "^10.1.2",
@@ -116,5 +117,5 @@
116
117
  "node": "20.1.0",
117
118
  "npm": "8.19.4"
118
119
  },
119
- "gitHead": "77534875918d98c75006123a910ebf89fd4fb1be"
120
+ "gitHead": "3ed2e8ed34419890228935f0cd59df80e7a10f1f"
120
121
  }