typescript 4.8.0-dev.20220614 → 4.8.0-dev.20220617

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.20220614";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220617";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -8463,9 +8463,11 @@ var ts;
8463
8463
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8464
8464
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8465
8465
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8466
- This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8466
+ This_type_parameter_might_need_an_extends_0_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."),
8467
8467
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8468
8468
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8469
+ Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
8470
+ Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
8469
8471
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
8470
8472
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
8471
8473
  Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -8951,6 +8953,8 @@ var ts;
8951
8953
  This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
8952
8954
  An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
8953
8955
  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'."),
8956
+ _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?"),
8957
+ 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."),
8954
8958
  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}'."),
8955
8959
  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}'."),
8956
8960
  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}'."),
@@ -9648,6 +9652,8 @@ var ts;
9648
9652
  Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
9649
9653
  A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
9650
9654
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
9655
+ You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."),
9656
+ You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
9651
9657
  Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
9652
9658
  Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
9653
9659
  JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
@@ -35765,10 +35771,11 @@ var ts;
35765
35771
  }
35766
35772
  nextToken();
35767
35773
  var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
35768
- if (!parseExpected(31 /* GreaterThanToken */)) {
35774
+ if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
35769
35775
  // If it doesn't have the closing `>` then it's definitely not an type argument list.
35770
35776
  return undefined;
35771
35777
  }
35778
+ nextToken();
35772
35779
  // We successfully parsed a type argument list. The next token determines whether we want to
35773
35780
  // treat it as such. If the type argument list is followed by `(` or a template literal, as in
35774
35781
  // `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
@@ -48885,9 +48892,9 @@ var ts;
48885
48892
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
48886
48893
  },
48887
48894
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
48888
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
48895
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
48889
48896
  var node = ts.getParseTreeNode(nodeIn);
48890
- return node && tryGetThisTypeAt(node, includeGlobalThis);
48897
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
48891
48898
  },
48892
48899
  getTypeArgumentConstraint: function (nodeIn) {
48893
48900
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -49182,6 +49189,7 @@ var ts;
49182
49189
  var potentialNewTargetCollisions = [];
49183
49190
  var potentialWeakMapSetCollisions = [];
49184
49191
  var potentialReflectCollisions = [];
49192
+ var potentialUnusedRenamedBindingElementsInTypes = [];
49185
49193
  var awaitedTypeStack = [];
49186
49194
  var diagnostics = ts.createDiagnosticCollection();
49187
49195
  var suggestionDiagnostics = ts.createDiagnosticCollection();
@@ -52517,6 +52525,9 @@ var ts;
52517
52525
  if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
52518
52526
  return { accessibility: 0 /* Accessible */ };
52519
52527
  }
52528
+ if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
52529
+ return { accessibility: 0 /* Accessible */ };
52530
+ }
52520
52531
  // Verify if the symbol is accessible
52521
52532
  return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
52522
52533
  accessibility: 1 /* NotAccessible */,
@@ -53689,15 +53700,22 @@ var ts;
53689
53700
  context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
53690
53701
  return parameterNode;
53691
53702
  function cloneBindingName(node) {
53692
- return elideInitializerAndSetEmitFlags(node);
53693
- function elideInitializerAndSetEmitFlags(node) {
53703
+ return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
53704
+ function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
53694
53705
  if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
53695
53706
  trackComputedName(node.expression, context.enclosingDeclaration, context);
53696
53707
  }
53697
- var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags);
53708
+ var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
53698
53709
  if (ts.isBindingElement(visited)) {
53699
- visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53700
- /*initializer*/ undefined);
53710
+ if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
53711
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
53712
+ /* propertyName*/ undefined, visited.propertyName,
53713
+ /*initializer*/ undefined);
53714
+ }
53715
+ else {
53716
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53717
+ /*initializer*/ undefined);
53718
+ }
53701
53719
  }
53702
53720
  if (!ts.nodeIsSynthesized(visited)) {
53703
53721
  visited = ts.factory.cloneNode(visited);
@@ -59324,7 +59342,7 @@ var ts;
59324
59342
  }
59325
59343
  if (t.flags & 268435456 /* StringMapping */) {
59326
59344
  var constraint = getBaseConstraint(t.type);
59327
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59345
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59328
59346
  }
59329
59347
  if (t.flags & 8388608 /* IndexedAccess */) {
59330
59348
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62294,9 +62312,12 @@ var ts;
62294
62312
  }
62295
62313
  function getStringMappingType(symbol, type) {
62296
62314
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62297
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62298
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62299
- type;
62315
+ // Mapping<Mapping<T>> === Mapping<T>
62316
+ type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
62317
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
62318
+ type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62319
+ type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
62320
+ type;
62300
62321
  }
62301
62322
  function applyStringMapping(symbol, str) {
62302
62323
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62307,6 +62328,15 @@ var ts;
62307
62328
  }
62308
62329
  return str;
62309
62330
  }
62331
+ function applyTemplateStringMapping(symbol, texts, types) {
62332
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
62333
+ case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62334
+ case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62335
+ case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62336
+ case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62337
+ }
62338
+ return [texts, types];
62339
+ }
62310
62340
  function getStringMappingTypeForGenericType(symbol, type) {
62311
62341
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62312
62342
  var result = stringMappingTypes.get(id);
@@ -62548,7 +62578,7 @@ var ts;
62548
62578
  accessNode;
62549
62579
  }
62550
62580
  function isPatternLiteralPlaceholderType(type) {
62551
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
62581
+ return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
62552
62582
  }
62553
62583
  function isPatternLiteralType(type) {
62554
62584
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -65470,8 +65500,13 @@ var ts;
65470
65500
  return;
65471
65501
  }
65472
65502
  reportRelationError(headMessage, source, target);
65473
- if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
65474
- associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65503
+ if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) {
65504
+ var syntheticParam = cloneTypeParameter(source);
65505
+ syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
65506
+ if (hasNonCircularBaseConstraint(syntheticParam)) {
65507
+ var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
65508
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
65509
+ }
65475
65510
  }
65476
65511
  }
65477
65512
  function traceUnionsOrIntersectionsTooLarge(source, target) {
@@ -66255,6 +66290,13 @@ var ts;
66255
66290
  return -1 /* True */;
66256
66291
  }
66257
66292
  }
66293
+ else if (target.flags & 268435456 /* StringMapping */) {
66294
+ if (!(source.flags & 268435456 /* StringMapping */)) {
66295
+ if (isMemberOfStringMapping(source, target)) {
66296
+ return -1 /* True */;
66297
+ }
66298
+ }
66299
+ }
66258
66300
  if (sourceFlags & 8650752 /* TypeVariable */) {
66259
66301
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66260
66302
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66298,7 +66340,10 @@ var ts;
66298
66340
  }
66299
66341
  }
66300
66342
  else if (sourceFlags & 268435456 /* StringMapping */) {
66301
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66343
+ if (targetFlags & 268435456 /* StringMapping */) {
66344
+ if (source.symbol !== target.symbol) {
66345
+ return 0 /* False */;
66346
+ }
66302
66347
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66303
66348
  resetErrorInfo(saveErrorInfo);
66304
66349
  return result;
@@ -67223,7 +67268,7 @@ var ts;
67223
67268
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67224
67269
  }
67225
67270
  }
67226
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67271
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67227
67272
  }
67228
67273
  function getExactOptionalUnassignableProperties(source, target) {
67229
67274
  if (isTupleType(source) && isTupleType(target))
@@ -68021,12 +68066,13 @@ var ts;
68021
68066
  * with no call or construct signatures.
68022
68067
  */
68023
68068
  function isObjectTypeWithInferableIndex(type) {
68069
+ var objectFlags = ts.getObjectFlags(type);
68024
68070
  return type.flags & 2097152 /* Intersection */
68025
68071
  ? ts.every(type.types, isObjectTypeWithInferableIndex)
68026
68072
  : !!(type.symbol
68027
68073
  && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
68028
68074
  && !(type.symbol.flags & 32 /* Class */)
68029
- && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68075
+ && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68030
68076
  }
68031
68077
  function createSymbolWithType(source, type) {
68032
68078
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
@@ -68693,6 +68739,31 @@ var ts;
68693
68739
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68694
68740
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68695
68741
  }
68742
+ function isMemberOfStringMapping(source, target) {
68743
+ if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
68744
+ return true;
68745
+ }
68746
+ if (target.flags & 134217728 /* TemplateLiteral */) {
68747
+ return isTypeAssignableTo(source, target);
68748
+ }
68749
+ if (target.flags & 268435456 /* StringMapping */) {
68750
+ // We need to see whether applying the same mappings of the target
68751
+ // onto the source would produce an identical type *and* that
68752
+ // it's compatible with the inner-most non-string-mapped type.
68753
+ //
68754
+ // The intuition here is that if same mappings don't affect the source at all,
68755
+ // and the source is compatible with the unmapped target, then they must
68756
+ // still reside in the same domain.
68757
+ var mappingStack = [];
68758
+ while (target.flags & 268435456 /* StringMapping */) {
68759
+ mappingStack.unshift(target.symbol);
68760
+ target = target.type;
68761
+ }
68762
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
68763
+ return mappedSource === source && isMemberOfStringMapping(source, target);
68764
+ }
68765
+ return false;
68766
+ }
68696
68767
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68697
68768
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68698
68769
  return true;
@@ -68701,7 +68772,8 @@ var ts;
68701
68772
  var value = source.value;
68702
68773
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68703
68774
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68704
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68775
+ target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
68776
+ target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68705
68777
  }
68706
68778
  if (source.flags & 134217728 /* TemplateLiteral */) {
68707
68779
  var texts = source.texts;
@@ -82625,6 +82697,22 @@ var ts;
82625
82697
  }
82626
82698
  });
82627
82699
  }
82700
+ function checkPotentialUncheckedRenamedBindingElementsInTypes() {
82701
+ var _a;
82702
+ for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
82703
+ var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
82704
+ if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
82705
+ var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
82706
+ ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
82707
+ var diagnostic = ts.createDiagnosticForNode(node.name, ts.Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, ts.declarationNameToString(node.name), ts.declarationNameToString(node.propertyName));
82708
+ if (!wrappingDeclaration.type) {
82709
+ // entire parameter does not have type annotation, suggest adding an annotation
82710
+ ts.addRelatedInfo(diagnostic, ts.createFileDiagnostic(ts.getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, ts.Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, ts.declarationNameToString(node.propertyName)));
82711
+ }
82712
+ diagnostics.add(diagnostic);
82713
+ }
82714
+ }
82715
+ }
82628
82716
  function bindingNameText(name) {
82629
82717
  switch (name.kind) {
82630
82718
  case 79 /* Identifier */:
@@ -82926,6 +83014,17 @@ var ts;
82926
83014
  }
82927
83015
  }
82928
83016
  if (ts.isBindingElement(node)) {
83017
+ if (node.propertyName &&
83018
+ ts.isIdentifier(node.name) &&
83019
+ ts.isParameterDeclaration(node) &&
83020
+ ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
83021
+ // type F = ({a: string}) => void;
83022
+ // ^^^^^^
83023
+ // variable renaming in function type notation is confusing,
83024
+ // so we forbid it even if noUnusedLocals is not enabled
83025
+ potentialUnusedRenamedBindingElementsInTypes.push(node);
83026
+ return;
83027
+ }
82929
83028
  if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
82930
83029
  checkExternalEmitHelpers(node, 4 /* Rest */);
82931
83030
  }
@@ -86389,6 +86488,7 @@ var ts;
86389
86488
  ts.clear(potentialNewTargetCollisions);
86390
86489
  ts.clear(potentialWeakMapSetCollisions);
86391
86490
  ts.clear(potentialReflectCollisions);
86491
+ ts.clear(potentialUnusedRenamedBindingElementsInTypes);
86392
86492
  ts.forEach(node.statements, checkSourceElement);
86393
86493
  checkSourceElement(node.endOfFileToken);
86394
86494
  checkDeferredNodes(node);
@@ -86404,6 +86504,9 @@ var ts;
86404
86504
  }
86405
86505
  });
86406
86506
  }
86507
+ if (!node.isDeclarationFile) {
86508
+ checkPotentialUncheckedRenamedBindingElementsInTypes();
86509
+ }
86407
86510
  });
86408
86511
  if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
86409
86512
  !node.isDeclarationFile &&
@@ -109145,7 +109248,7 @@ var ts;
109145
109248
  });
109146
109249
  return ret;
109147
109250
  }
109148
- function filterBindingPatternInitializers(name) {
109251
+ function filterBindingPatternInitializersAndRenamings(name) {
109149
109252
  if (name.kind === 79 /* Identifier */) {
109150
109253
  return name;
109151
109254
  }
@@ -109161,7 +109264,12 @@ var ts;
109161
109264
  if (elem.kind === 227 /* OmittedExpression */) {
109162
109265
  return elem;
109163
109266
  }
109164
- return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109267
+ if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
109268
+ // Unnecessary property renaming is forbidden in types, so remove renaming
109269
+ return factory.updateBindingElement(elem, elem.dotDotDotToken,
109270
+ /* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109271
+ }
109272
+ return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109165
109273
  }
109166
109274
  }
109167
109275
  function ensureParameter(p, modifierMask, type) {
@@ -109170,7 +109278,7 @@ var ts;
109170
109278
  oldDiag = getSymbolAccessibilityDiagnostic;
109171
109279
  getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
109172
109280
  }
109173
- var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
109281
+ var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
109174
109282
  ensureNoInitializer(p));
109175
109283
  if (!suppressNewDiagnosticContexts) {
109176
109284
  getSymbolAccessibilityDiagnostic = oldDiag;
@@ -117313,6 +117421,7 @@ var ts;
117313
117421
  ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
117314
117422
  ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
117315
117423
  ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
117424
+ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
117316
117425
  ]);
117317
117426
  /**
117318
117427
  * Determine if source file needs to be re-created even if its text hasn't changed
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.20220614",
5
+ "version": "4.8.0-dev.20220617",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [
@@ -33,12 +33,13 @@
33
33
  "@octokit/rest": "latest",
34
34
  "@types/chai": "latest",
35
35
  "@types/convert-source-map": "latest",
36
+ "@types/fs-extra": "^9.0.13",
36
37
  "@types/glob": "latest",
37
38
  "@types/gulp": "^4.0.9",
38
39
  "@types/gulp-concat": "latest",
39
40
  "@types/gulp-newer": "latest",
40
- "@types/gulp-rename": "0.0.33",
41
- "@types/gulp-sourcemaps": "0.0.32",
41
+ "@types/gulp-rename": "latest",
42
+ "@types/gulp-sourcemaps": "latest",
42
43
  "@types/merge2": "latest",
43
44
  "@types/microsoft__typescript-etw": "latest",
44
45
  "@types/minimatch": "latest",
@@ -47,29 +48,28 @@
47
48
  "@types/mocha": "latest",
48
49
  "@types/ms": "latest",
49
50
  "@types/node": "latest",
50
- "@types/node-fetch": "^2.3.4",
51
51
  "@types/q": "latest",
52
52
  "@types/source-map-support": "latest",
53
- "@types/xml2js": "^0.4.0",
54
- "@typescript-eslint/eslint-plugin": "^4.28.0",
55
- "@typescript-eslint/experimental-utils": "^4.28.0",
56
- "@typescript-eslint/parser": "^4.28.0",
53
+ "@types/xml2js": "^0.4.11",
54
+ "@typescript-eslint/eslint-plugin": "^5.28.0",
55
+ "@typescript-eslint/parser": "^5.28.0",
56
+ "@typescript-eslint/utils": "^5.28.0",
57
57
  "async": "latest",
58
- "azure-devops-node-api": "^11.0.1",
58
+ "azure-devops-node-api": "^11.1.1",
59
59
  "chai": "latest",
60
60
  "chalk": "^4.1.2",
61
61
  "convert-source-map": "latest",
62
- "del": "5.1.0",
63
- "diff": "^4.0.2",
64
- "eslint": "7.12.1",
65
- "eslint-formatter-autolinkable-stylish": "1.1.4",
66
- "eslint-plugin-import": "2.22.1",
67
- "eslint-plugin-jsdoc": "30.7.6",
62
+ "del": "6.1.1",
63
+ "diff": "^5.1.0",
64
+ "eslint": "8.17.0",
65
+ "eslint-formatter-autolinkable-stylish": "1.2.0",
66
+ "eslint-plugin-import": "2.26.0",
67
+ "eslint-plugin-jsdoc": "39.3.2",
68
68
  "eslint-plugin-no-null": "1.0.2",
69
69
  "fancy-log": "latest",
70
- "fs-extra": "^9.0.0",
70
+ "fs-extra": "^9.1.0",
71
71
  "glob": "latest",
72
- "gulp": "^4.0.0",
72
+ "gulp": "^4.0.2",
73
73
  "gulp-concat": "latest",
74
74
  "gulp-insert": "latest",
75
75
  "gulp-newer": "latest",
@@ -81,14 +81,14 @@
81
81
  "mocha": "latest",
82
82
  "mocha-fivemat-progress-reporter": "latest",
83
83
  "ms": "^2.1.3",
84
- "node-fetch": "^2.6.1",
85
- "prex": "^0.4.3",
84
+ "node-fetch": "^3.2.6",
85
+ "prex": "^0.4.7",
86
86
  "q": "latest",
87
87
  "source-map-support": "latest",
88
88
  "typescript": "^4.5.5",
89
89
  "vinyl": "latest",
90
90
  "vinyl-sourcemaps-apply": "latest",
91
- "xml2js": "^0.4.19"
91
+ "xml2js": "^0.4.23"
92
92
  },
93
93
  "scripts": {
94
94
  "prepare": "gulp build-eslint-rules",