typescript 4.8.0-dev.20220726 → 4.8.0-dev.20220729

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.
@@ -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.20220726";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220729";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -1690,6 +1690,10 @@ var ts;
1690
1690
  /** Does nothing. */
1691
1691
  function noop(_) { }
1692
1692
  ts.noop = noop;
1693
+ ts.noopPush = {
1694
+ push: noop,
1695
+ length: 0
1696
+ };
1693
1697
  /** Do nothing and return false */
1694
1698
  function returnFalse() {
1695
1699
  return false;
@@ -8557,6 +8561,7 @@ var ts;
8557
8561
  Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."),
8558
8562
  auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."),
8559
8563
  An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."),
8564
+ Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."),
8560
8565
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
8561
8566
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
8562
8567
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
@@ -8770,6 +8775,7 @@ var ts;
8770
8775
  Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."),
8771
8776
  Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."),
8772
8777
  Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."),
8778
+ A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."),
8773
8779
  Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."),
8774
8780
  All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."),
8775
8781
  Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."),
@@ -33296,7 +33302,9 @@ var ts;
33296
33302
  case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
33297
33303
  case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
33298
33304
  case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
33299
- default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);`
33305
+ case 24 /* AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey.
33306
+ case 25 /* Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker.
33307
+ default: ts.Debug.assertNever(context);
33300
33308
  }
33301
33309
  }
33302
33310
  function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
@@ -43122,18 +43130,7 @@ var ts;
43122
43130
  * Does not try `@types/${packageName}` - use a second pass if needed.
43123
43131
  */
43124
43132
  function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) {
43125
- var moduleResolutionState = {
43126
- compilerOptions: options,
43127
- host: host,
43128
- traceEnabled: isTraceEnabled(options, host),
43129
- failedLookupLocations: [],
43130
- affectingLocations: [],
43131
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
43132
- conditions: ts.emptyArray,
43133
- features: NodeResolutionFeatures.None,
43134
- requestContainingDirectory: containingDirectory,
43135
- reportDiagnostic: ts.noop
43136
- };
43133
+ var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
43137
43134
  return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
43138
43135
  if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
43139
43136
  var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules");
@@ -44093,18 +44090,9 @@ var ts;
44093
44090
  var entrypoints;
44094
44091
  var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript;
44095
44092
  var features = getDefaultNodeResolutionFeatures(options);
44096
- var requireState = {
44097
- compilerOptions: options,
44098
- host: host,
44099
- traceEnabled: isTraceEnabled(options, host),
44100
- failedLookupLocations: [],
44101
- affectingLocations: [],
44102
- packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
44103
- conditions: ["node", "require", "types"],
44104
- features: features,
44105
- requestContainingDirectory: packageJsonInfo.packageDirectory,
44106
- reportDiagnostic: ts.noop
44107
- };
44093
+ var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options);
44094
+ requireState.conditions = ["node", "require", "types"];
44095
+ requireState.requestContainingDirectory = packageJsonInfo.packageDirectory;
44108
44096
  var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
44109
44097
  /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
44110
44098
  entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path);
@@ -44177,23 +44165,27 @@ var ts;
44177
44165
  }
44178
44166
  }
44179
44167
  }
44180
- /**
44181
- * A function for locating the package.json scope for a given path
44182
- */
44183
44168
  /*@internal*/
44184
- function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) {
44185
- var state = {
44169
+ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) {
44170
+ return {
44186
44171
  host: host,
44187
44172
  compilerOptions: options,
44188
44173
  traceEnabled: isTraceEnabled(options, host),
44189
- failedLookupLocations: [],
44190
- affectingLocations: [],
44174
+ failedLookupLocations: ts.noopPush,
44175
+ affectingLocations: ts.noopPush,
44191
44176
  packageJsonInfoCache: packageJsonInfoCache,
44192
- features: 0,
44193
- conditions: [],
44177
+ features: NodeResolutionFeatures.None,
44178
+ conditions: ts.emptyArray,
44194
44179
  requestContainingDirectory: undefined,
44195
44180
  reportDiagnostic: ts.noop
44196
44181
  };
44182
+ }
44183
+ ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState;
44184
+ /**
44185
+ * A function for locating the package.json scope for a given path
44186
+ */
44187
+ /*@internal*/
44188
+ function getPackageScopeForPath(fileName, state) {
44197
44189
  var parts = ts.getPathComponents(fileName);
44198
44190
  parts.pop();
44199
44191
  while (parts.length > 0) {
@@ -44364,7 +44356,7 @@ var ts;
44364
44356
  var _a, _b;
44365
44357
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44366
44358
  var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44367
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
44359
+ var scope = getPackageScopeForPath(directoryPath, state);
44368
44360
  if (!scope || !scope.packageJsonContent.exports) {
44369
44361
  return undefined;
44370
44362
  }
@@ -44423,7 +44415,7 @@ var ts;
44423
44415
  }
44424
44416
  var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames;
44425
44417
  var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames));
44426
- var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions);
44418
+ var scope = getPackageScopeForPath(directoryPath, state);
44427
44419
  if (!scope) {
44428
44420
  if (state.traceEnabled) {
44429
44421
  trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath);
@@ -52883,6 +52875,12 @@ var ts;
52883
52875
  return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
52884
52876
  }
52885
52877
  function typeToTypeNodeHelper(type, context) {
52878
+ var savedFlags = context.flags;
52879
+ var typeNode = typeToTypeNodeWorker(type, context);
52880
+ context.flags = savedFlags;
52881
+ return typeNode;
52882
+ }
52883
+ function typeToTypeNodeWorker(type, context) {
52886
52884
  if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
52887
52885
  cancellationToken.throwIfCancellationRequested();
52888
52886
  }
@@ -59402,7 +59400,8 @@ var ts;
59402
59400
  }
59403
59401
  }
59404
59402
  }
59405
- return getIntersectionType(constraints);
59403
+ // The source types were normalized; ensure the result is normalized too.
59404
+ return getNormalizedType(getIntersectionType(constraints), /*writing*/ false);
59406
59405
  }
59407
59406
  return undefined;
59408
59407
  }
@@ -62620,21 +62619,28 @@ var ts;
62620
62619
  getFlowTypeOfReference(accessExpression, propType) :
62621
62620
  propType;
62622
62621
  }
62623
- if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) {
62622
+ if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) {
62623
+ var index = +propName;
62624
62624
  if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) {
62625
62625
  var indexNode = getIndexNodeForAccessExpression(accessNode);
62626
62626
  if (isTupleType(objectType)) {
62627
+ if (index < 0) {
62628
+ error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value);
62629
+ return undefinedType;
62630
+ }
62627
62631
  error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
62628
62632
  }
62629
62633
  else {
62630
62634
  error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
62631
62635
  }
62632
62636
  }
62633
- errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
62634
- return mapType(objectType, function (t) {
62635
- var restType = getRestTypeOfTupleType(t) || undefinedType;
62636
- return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
62637
- });
62637
+ if (index >= 0) {
62638
+ errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType));
62639
+ return mapType(objectType, function (t) {
62640
+ var restType = getRestTypeOfTupleType(t) || undefinedType;
62641
+ return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType;
62642
+ });
62643
+ }
62638
62644
  }
62639
62645
  }
62640
62646
  if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) {
@@ -71928,8 +71934,12 @@ var ts;
71928
71934
  var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName);
71929
71935
  var matching = discriminant && getConstituentTypeForKeyType(type, discriminant);
71930
71936
  // For each constituent t in the current type, if t and and c are directly related, pick the most
71931
- // specific of the two.
71932
- var directlyRelated = mapType(matching || type, function (t) { return isRelated(t, c) ? t : isRelated(c, t) ? c : neverType; });
71937
+ // specific of the two. When t and c are related in both directions, we prefer c for type predicates
71938
+ // because that is the asserted type, but t for `instanceof` because generics aren't reflected in
71939
+ // prototype object types.
71940
+ var directlyRelated = mapType(matching || type, checkDerived ?
71941
+ function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } :
71942
+ function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; });
71933
71943
  // If no constituents are directly related, create intersections for any generic constituents that
71934
71944
  // are related by constraint.
71935
71945
  return directlyRelated.flags & 131072 /* Never */ ?
@@ -84641,8 +84651,9 @@ var ts;
84641
84651
  }
84642
84652
  var indexInfos = getApplicableIndexInfos(type, propNameType);
84643
84653
  var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined;
84644
- var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
84645
- name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
84654
+ var propDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ ||
84655
+ name && name.kind === 162 /* ComputedPropertyName */ ? declaration : undefined;
84656
+ var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
84646
84657
  var _loop_30 = function (info) {
84647
84658
  var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
84648
84659
  // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
@@ -84651,7 +84662,11 @@ var ts;
84651
84662
  var errorNode = localPropDeclaration || localIndexDeclaration ||
84652
84663
  (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined);
84653
84664
  if (errorNode && !isTypeAssignableTo(propType, info.type)) {
84654
- error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
84665
+ var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
84666
+ if (propDeclaration && errorNode !== propDeclaration) {
84667
+ ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop)));
84668
+ }
84669
+ diagnostics.add(diagnostic);
84655
84670
  }
84656
84671
  };
84657
84672
  for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
@@ -117636,7 +117651,7 @@ var ts;
117636
117651
  return undefined;
117637
117652
  }
117638
117653
  function lookupFromPackageJson() {
117639
- var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options);
117654
+ var scope = ts.getPackageScopeForPath(fileName, ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options));
117640
117655
  return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS;
117641
117656
  }
117642
117657
  }
@@ -118302,7 +118317,7 @@ var ts;
118302
118317
  // `result[i]` is either a `ResolvedModuleFull` or a marker.
118303
118318
  // If it is the former, we can leave it as is.
118304
118319
  if (result[i] === predictedToResolveToAmbientModuleMarker) {
118305
- result[i] = undefined; // TODO: GH#18217
118320
+ result[i] = undefined;
118306
118321
  }
118307
118322
  }
118308
118323
  else {
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.20220726",
5
+ "version": "4.8.0-dev.20220729",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -28,7 +28,6 @@
28
28
  "engines": {
29
29
  "node": ">=4.2.0"
30
30
  },
31
- "packageManager": "npm@6.14.15",
32
31
  "devDependencies": {
33
32
  "@octokit/rest": "latest",
34
33
  "@types/chai": "latest",
@@ -118,7 +117,9 @@
118
117
  "source-map-support": false,
119
118
  "inspector": false
120
119
  },
120
+ "packageManager": "npm@8.15.0",
121
121
  "volta": {
122
- "node": "14.15.5"
122
+ "node": "14.20.0",
123
+ "npm": "8.15.0"
123
124
  }
124
125
  }