typescript 4.8.0-dev.20220707 → 4.8.0-dev.20220708

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.20220707";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220708";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -2045,7 +2045,7 @@ var ts;
2045
2045
  * and 1 insertion/deletion at 3 characters)
2046
2046
  */
2047
2047
  function getSpellingSuggestion(name, candidates, getName) {
2048
- var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
2048
+ var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
2049
2049
  var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother.
2050
2050
  var bestCandidate;
2051
2051
  for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) {
@@ -9029,6 +9029,7 @@ var ts;
9029
9029
  The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
9030
9030
  _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
9031
9031
  We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
9032
+ Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
9032
9033
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
9033
9034
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
9034
9035
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -44408,6 +44409,7 @@ var ts;
44408
44409
  return toSearchResult(/*value*/ undefined);
44409
44410
  }
44410
44411
  /**
44412
+ * @internal
44411
44413
  * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 -
44412
44414
  * "longest" has some nuance as to what "longest" means in the presence of pattern trailers
44413
44415
  */
@@ -44430,6 +44432,7 @@ var ts;
44430
44432
  return 1;
44431
44433
  return 0;
44432
44434
  }
44435
+ ts.comparePatternKeys = comparePatternKeys;
44433
44436
  function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
44434
44437
  var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
44435
44438
  if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
@@ -50236,6 +50239,7 @@ var ts;
50236
50239
  if (ctor && ctor.locals) {
50237
50240
  if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) {
50238
50241
  // Remember the property node, it will be used later to report appropriate error
50242
+ ts.Debug.assertNode(location, ts.isPropertyDeclaration);
50239
50243
  propertyWithInvalidInitializer = location;
50240
50244
  }
50241
50245
  }
@@ -50425,11 +50429,27 @@ var ts;
50425
50429
  }
50426
50430
  }
50427
50431
  }
50432
+ // The invalid initializer error is needed in two situation:
50433
+ // 1. When result is undefined, after checking for a missing "this."
50434
+ // 2. When result is defined
50435
+ function checkAndReportErrorForInvalidInitializer() {
50436
+ if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50437
+ // We have a match, but the reference occurred within a property initializer and the identifier also binds
50438
+ // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50439
+ // with ESNext+useDefineForClassFields because the scope semantics are different.
50440
+ error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos)
50441
+ ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor
50442
+ : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg));
50443
+ return true;
50444
+ }
50445
+ return false;
50446
+ }
50428
50447
  if (!result) {
50429
50448
  if (nameNotFoundMessage) {
50430
50449
  addLazyDiagnostic(function () {
50431
50450
  if (!errorLocation ||
50432
50451
  !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217
50452
+ !checkAndReportErrorForInvalidInitializer() &&
50433
50453
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50434
50454
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50435
50455
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
@@ -50437,7 +50457,16 @@ var ts;
50437
50457
  !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50438
50458
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50439
50459
  var suggestion = void 0;
50440
- if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50460
+ var suggestedLib = void 0;
50461
+ // Report missing lib first
50462
+ if (nameArg) {
50463
+ suggestedLib = getSuggestedLibForNonExistentName(nameArg);
50464
+ if (suggestedLib) {
50465
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib);
50466
+ }
50467
+ }
50468
+ // then spelling suggestions
50469
+ if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) {
50441
50470
  suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
50442
50471
  var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
50443
50472
  if (isGlobalScopeAugmentationDeclaration) {
@@ -50456,16 +50485,9 @@ var ts;
50456
50485
  }
50457
50486
  }
50458
50487
  }
50459
- if (!suggestion) {
50460
- if (nameArg) {
50461
- var lib = getSuggestedLibForNonExistentName(nameArg);
50462
- if (lib) {
50463
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
50464
- }
50465
- else {
50466
- error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50467
- }
50468
- }
50488
+ // And then fall back to unspecified "not found"
50489
+ if (!suggestion && !suggestedLib && nameArg) {
50490
+ error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
50469
50491
  }
50470
50492
  suggestionCount++;
50471
50493
  }
@@ -50473,12 +50495,7 @@ var ts;
50473
50495
  }
50474
50496
  return undefined;
50475
50497
  }
50476
- if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) {
50477
- // We have a match, but the reference occurred within a property initializer and the identifier also binds
50478
- // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed
50479
- // with ESNext+useDefineForClassFields because the scope semantics are different.
50480
- var propertyName = propertyWithInvalidInitializer.name;
50481
- error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
50498
+ else if (checkAndReportErrorForInvalidInitializer()) {
50482
50499
  return undefined;
50483
50500
  }
50484
50501
  // Perform extra checks only if error reporting was requested
@@ -62345,19 +62362,22 @@ var ts;
62345
62362
  * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible).
62346
62363
  */
62347
62364
  function isPossiblyReducibleByInstantiation(type) {
62348
- return ts.some(type.types, function (t) {
62349
- var uniqueFilled = getUniqueLiteralFilledInstantiation(t);
62350
- return getReducedType(uniqueFilled) !== uniqueFilled;
62351
- });
62365
+ var uniqueFilled = getUniqueLiteralFilledInstantiation(type);
62366
+ return getReducedType(uniqueFilled) !== uniqueFilled;
62367
+ }
62368
+ function shouldDeferIndexType(type) {
62369
+ return !!(type.flags & 58982400 /* InstantiableNonPrimitive */ ||
62370
+ isGenericTupleType(type) ||
62371
+ isGenericMappedType(type) && !hasDistributiveNameType(type) ||
62372
+ type.flags & 1048576 /* Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) ||
62373
+ type.flags & 2097152 /* Intersection */ && maybeTypeOfKind(type, 465829888 /* Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType));
62352
62374
  }
62353
62375
  function getIndexType(type, stringsOnly, noIndexSignatures) {
62354
62376
  if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
62355
62377
  type = getReducedType(type);
62356
- return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type)
62357
- ? getIndexTypeForGenericType(type, stringsOnly)
62358
- : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62359
- type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62360
- type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62378
+ return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) :
62379
+ type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62380
+ type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
62361
62381
  ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) :
62362
62382
  type === wildcardType ? wildcardType :
62363
62383
  type.flags & 2 /* Unknown */ ? neverType :
@@ -69947,6 +69967,15 @@ var ts;
69947
69967
  var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
69948
69968
  return key && key + "." + propName;
69949
69969
  }
69970
+ break;
69971
+ case 201 /* ObjectBindingPattern */:
69972
+ case 202 /* ArrayBindingPattern */:
69973
+ case 256 /* FunctionDeclaration */:
69974
+ case 213 /* FunctionExpression */:
69975
+ case 214 /* ArrowFunction */:
69976
+ case 169 /* MethodDeclaration */:
69977
+ // Handle pseudo-references originating in getNarrowedTypeOfSymbol.
69978
+ return getNodeId(node) + "#" + getTypeId(declaredType);
69950
69979
  }
69951
69980
  return undefined;
69952
69981
  }
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.20220707",
5
+ "version": "4.8.0-dev.20220708",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [