typescript 4.8.0-dev.20220616 → 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.
@@ -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.20220616";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220617";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -9857,6 +9857,8 @@ var ts;
9857
9857
  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}'."),
9858
9858
  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."),
9859
9859
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
9860
+ 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."),
9861
+ 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."),
9860
9862
  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."),
9861
9863
  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."),
9862
9864
  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'."),
@@ -49095,9 +49097,9 @@ var ts;
49095
49097
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
49096
49098
  },
49097
49099
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
49098
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
49100
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
49099
49101
  var node = ts.getParseTreeNode(nodeIn);
49100
- return node && tryGetThisTypeAt(node, includeGlobalThis);
49102
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
49101
49103
  },
49102
49104
  getTypeArgumentConstraint: function (nodeIn) {
49103
49105
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -59545,7 +59547,7 @@ var ts;
59545
59547
  }
59546
59548
  if (t.flags & 268435456 /* StringMapping */) {
59547
59549
  var constraint = getBaseConstraint(t.type);
59548
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59550
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59549
59551
  }
59550
59552
  if (t.flags & 8388608 /* IndexedAccess */) {
59551
59553
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62515,9 +62517,12 @@ var ts;
62515
62517
  }
62516
62518
  function getStringMappingType(symbol, type) {
62517
62519
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62518
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62519
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62520
- type;
62520
+ // Mapping<Mapping<T>> === Mapping<T>
62521
+ type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
62522
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
62523
+ type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62524
+ type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
62525
+ type;
62521
62526
  }
62522
62527
  function applyStringMapping(symbol, str) {
62523
62528
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62528,6 +62533,15 @@ var ts;
62528
62533
  }
62529
62534
  return str;
62530
62535
  }
62536
+ function applyTemplateStringMapping(symbol, texts, types) {
62537
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
62538
+ case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62539
+ case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62540
+ 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];
62541
+ 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];
62542
+ }
62543
+ return [texts, types];
62544
+ }
62531
62545
  function getStringMappingTypeForGenericType(symbol, type) {
62532
62546
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62533
62547
  var result = stringMappingTypes.get(id);
@@ -62769,7 +62783,7 @@ var ts;
62769
62783
  accessNode;
62770
62784
  }
62771
62785
  function isPatternLiteralPlaceholderType(type) {
62772
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
62786
+ return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
62773
62787
  }
62774
62788
  function isPatternLiteralType(type) {
62775
62789
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -66481,6 +66495,13 @@ var ts;
66481
66495
  return -1 /* True */;
66482
66496
  }
66483
66497
  }
66498
+ else if (target.flags & 268435456 /* StringMapping */) {
66499
+ if (!(source.flags & 268435456 /* StringMapping */)) {
66500
+ if (isMemberOfStringMapping(source, target)) {
66501
+ return -1 /* True */;
66502
+ }
66503
+ }
66504
+ }
66484
66505
  if (sourceFlags & 8650752 /* TypeVariable */) {
66485
66506
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66486
66507
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66524,7 +66545,10 @@ var ts;
66524
66545
  }
66525
66546
  }
66526
66547
  else if (sourceFlags & 268435456 /* StringMapping */) {
66527
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66548
+ if (targetFlags & 268435456 /* StringMapping */) {
66549
+ if (source.symbol !== target.symbol) {
66550
+ return 0 /* False */;
66551
+ }
66528
66552
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66529
66553
  resetErrorInfo(saveErrorInfo);
66530
66554
  return result;
@@ -67449,7 +67473,7 @@ var ts;
67449
67473
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67450
67474
  }
67451
67475
  }
67452
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67476
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67453
67477
  }
67454
67478
  function getExactOptionalUnassignableProperties(source, target) {
67455
67479
  if (isTupleType(source) && isTupleType(target))
@@ -68920,6 +68944,31 @@ var ts;
68920
68944
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68921
68945
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68922
68946
  }
68947
+ function isMemberOfStringMapping(source, target) {
68948
+ if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
68949
+ return true;
68950
+ }
68951
+ if (target.flags & 134217728 /* TemplateLiteral */) {
68952
+ return isTypeAssignableTo(source, target);
68953
+ }
68954
+ if (target.flags & 268435456 /* StringMapping */) {
68955
+ // We need to see whether applying the same mappings of the target
68956
+ // onto the source would produce an identical type *and* that
68957
+ // it's compatible with the inner-most non-string-mapped type.
68958
+ //
68959
+ // The intuition here is that if same mappings don't affect the source at all,
68960
+ // and the source is compatible with the unmapped target, then they must
68961
+ // still reside in the same domain.
68962
+ var mappingStack = [];
68963
+ while (target.flags & 268435456 /* StringMapping */) {
68964
+ mappingStack.unshift(target.symbol);
68965
+ target = target.type;
68966
+ }
68967
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
68968
+ return mappedSource === source && isMemberOfStringMapping(source, target);
68969
+ }
68970
+ return false;
68971
+ }
68923
68972
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68924
68973
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68925
68974
  return true;
@@ -68928,7 +68977,8 @@ var ts;
68928
68977
  var value = source.value;
68929
68978
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68930
68979
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68931
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68980
+ target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
68981
+ target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68932
68982
  }
68933
68983
  if (source.flags & 134217728 /* TemplateLiteral */) {
68934
68984
  var texts = source.texts;
@@ -135386,7 +135436,7 @@ var ts;
135386
135436
  }
135387
135437
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
135388
135438
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
135389
- var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
135439
+ var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
135390
135440
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
135391
135441
  for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
135392
135442
  var symbol = _a[_i];
@@ -144724,10 +144774,10 @@ var ts;
144724
144774
  (function (ts) {
144725
144775
  var Rename;
144726
144776
  (function (Rename) {
144727
- function getRenameInfo(program, sourceFile, position, options) {
144777
+ function getRenameInfo(program, sourceFile, position, preferences) {
144728
144778
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
144729
144779
  if (nodeIsEligibleForRename(node)) {
144730
- var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options);
144780
+ var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
144731
144781
  if (renameInfo) {
144732
144782
  return renameInfo;
144733
144783
  }
@@ -144735,7 +144785,7 @@ var ts;
144735
144785
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
144736
144786
  }
144737
144787
  Rename.getRenameInfo = getRenameInfo;
144738
- function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) {
144788
+ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
144739
144789
  var symbol = typeChecker.getSymbolAtLocation(node);
144740
144790
  if (!symbol) {
144741
144791
  if (ts.isStringLiteralLike(node)) {
@@ -144763,7 +144813,12 @@ var ts;
144763
144813
  return undefined;
144764
144814
  }
144765
144815
  if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
144766
- return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144816
+ return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144817
+ }
144818
+ // Disallow rename for elements that would rename across `*/node_modules/*` packages.
144819
+ var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
144820
+ if (wouldRenameNodeModules) {
144821
+ return getRenameInfoError(wouldRenameNodeModules);
144767
144822
  }
144768
144823
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
144769
144824
  var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
@@ -144777,6 +144832,49 @@ var ts;
144777
144832
  var sourceFile = declaration.getSourceFile();
144778
144833
  return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
144779
144834
  }
144835
+ function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
144836
+ if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
144837
+ var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
144838
+ if (importSpecifier && !importSpecifier.propertyName) {
144839
+ symbol = checker.getAliasedSymbol(symbol);
144840
+ }
144841
+ }
144842
+ var declarations = symbol.declarations;
144843
+ if (!declarations) {
144844
+ return undefined;
144845
+ }
144846
+ var originalPackage = getPackagePathComponents(originalFile.path);
144847
+ if (originalPackage === undefined) { // original source file is not in node_modules
144848
+ if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
144849
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
144850
+ }
144851
+ else {
144852
+ return undefined;
144853
+ }
144854
+ }
144855
+ // original source file is in node_modules
144856
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
144857
+ var declaration = declarations_4[_i];
144858
+ var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
144859
+ if (declPackage) {
144860
+ var length_2 = Math.min(originalPackage.length, declPackage.length);
144861
+ for (var i = 0; i <= length_2; i++) {
144862
+ if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
144863
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
144864
+ }
144865
+ }
144866
+ }
144867
+ }
144868
+ return undefined;
144869
+ }
144870
+ function getPackagePathComponents(filePath) {
144871
+ var components = ts.getPathComponents(filePath);
144872
+ var nodeModulesIdx = components.lastIndexOf("node_modules");
144873
+ if (nodeModulesIdx === -1) {
144874
+ return undefined;
144875
+ }
144876
+ return components.slice(0, nodeModulesIdx + 2);
144877
+ }
144780
144878
  function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
144781
144879
  if (!ts.isExternalModuleNameRelative(node.text)) {
144782
144880
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
@@ -161816,11 +161914,11 @@ var ts;
161816
161914
  }
161817
161915
  }
161818
161916
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
161819
- var declarations_5 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161917
+ var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161820
161918
  var numInitializers = 0;
161821
161919
  var lastInitializer = void 0;
161822
- for (var _i = 0, declarations_4 = declarations_5; _i < declarations_4.length; _i++) {
161823
- var declaration = declarations_4[_i];
161920
+ for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
161921
+ var declaration = declarations_5[_i];
161824
161922
  if (declaration.initializer) {
161825
161923
  numInitializers++;
161826
161924
  lastInitializer = declaration.initializer;
@@ -165957,8 +166055,8 @@ var ts;
165957
166055
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
165958
166056
  }
165959
166057
  };
165960
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
165961
- var declaration = declarations_6[_i];
166058
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
166059
+ var declaration = declarations_7[_i];
165962
166060
  _loop_21(declaration);
165963
166061
  }
165964
166062
  }
@@ -165984,8 +166082,8 @@ var ts;
165984
166082
  if (inheritedDocs)
165985
166083
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
165986
166084
  };
165987
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165988
- var declaration = declarations_7[_i];
166085
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
166086
+ var declaration = declarations_8[_i];
165989
166087
  _loop_22(declaration);
165990
166088
  }
165991
166089
  }
@@ -167562,9 +167660,9 @@ var ts;
167562
167660
  return ts.stringContains(path, "/node_modules/");
167563
167661
  }
167564
167662
  }
167565
- function getRenameInfo(fileName, position, options) {
167663
+ function getRenameInfo(fileName, position, preferences) {
167566
167664
  synchronizeHostData();
167567
- return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options);
167665
+ return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
167568
167666
  }
167569
167667
  function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
167570
167668
  var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
@@ -168930,9 +169028,9 @@ var ts;
168930
169028
  var _this = this;
168931
169029
  return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
168932
169030
  };
168933
- LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) {
169031
+ LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
168934
169032
  var _this = this;
168935
- return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); });
169033
+ return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
168936
169034
  };
168937
169035
  LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
168938
169036
  var _this = this;
@@ -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.20220616";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220617";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -9652,6 +9652,8 @@ var ts;
9652
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}'."),
9653
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."),
9654
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."),
9655
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."),
9656
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."),
9657
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'."),
@@ -48890,9 +48892,9 @@ var ts;
48890
48892
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
48891
48893
  },
48892
48894
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
48893
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
48895
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
48894
48896
  var node = ts.getParseTreeNode(nodeIn);
48895
- return node && tryGetThisTypeAt(node, includeGlobalThis);
48897
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
48896
48898
  },
48897
48899
  getTypeArgumentConstraint: function (nodeIn) {
48898
48900
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -59340,7 +59342,7 @@ var ts;
59340
59342
  }
59341
59343
  if (t.flags & 268435456 /* StringMapping */) {
59342
59344
  var constraint = getBaseConstraint(t.type);
59343
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59345
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59344
59346
  }
59345
59347
  if (t.flags & 8388608 /* IndexedAccess */) {
59346
59348
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62310,9 +62312,12 @@ var ts;
62310
62312
  }
62311
62313
  function getStringMappingType(symbol, type) {
62312
62314
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62313
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62314
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62315
- 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;
62316
62321
  }
62317
62322
  function applyStringMapping(symbol, str) {
62318
62323
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62323,6 +62328,15 @@ var ts;
62323
62328
  }
62324
62329
  return str;
62325
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
+ }
62326
62340
  function getStringMappingTypeForGenericType(symbol, type) {
62327
62341
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62328
62342
  var result = stringMappingTypes.get(id);
@@ -62564,7 +62578,7 @@ var ts;
62564
62578
  accessNode;
62565
62579
  }
62566
62580
  function isPatternLiteralPlaceholderType(type) {
62567
- 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));
62568
62582
  }
62569
62583
  function isPatternLiteralType(type) {
62570
62584
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -66276,6 +66290,13 @@ var ts;
66276
66290
  return -1 /* True */;
66277
66291
  }
66278
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
+ }
66279
66300
  if (sourceFlags & 8650752 /* TypeVariable */) {
66280
66301
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66281
66302
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66319,7 +66340,10 @@ var ts;
66319
66340
  }
66320
66341
  }
66321
66342
  else if (sourceFlags & 268435456 /* StringMapping */) {
66322
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66343
+ if (targetFlags & 268435456 /* StringMapping */) {
66344
+ if (source.symbol !== target.symbol) {
66345
+ return 0 /* False */;
66346
+ }
66323
66347
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66324
66348
  resetErrorInfo(saveErrorInfo);
66325
66349
  return result;
@@ -67244,7 +67268,7 @@ var ts;
67244
67268
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67245
67269
  }
67246
67270
  }
67247
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67271
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67248
67272
  }
67249
67273
  function getExactOptionalUnassignableProperties(source, target) {
67250
67274
  if (isTupleType(source) && isTupleType(target))
@@ -68715,6 +68739,31 @@ var ts;
68715
68739
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68716
68740
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68717
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
+ }
68718
68767
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68719
68768
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68720
68769
  return true;
@@ -68723,7 +68772,8 @@ var ts;
68723
68772
  var value = source.value;
68724
68773
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68725
68774
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68726
- 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));
68727
68777
  }
68728
68778
  if (source.flags & 134217728 /* TemplateLiteral */) {
68729
68779
  var texts = source.texts;
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.20220616",
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": [
@@ -38,8 +38,8 @@
38
38
  "@types/gulp": "^4.0.9",
39
39
  "@types/gulp-concat": "latest",
40
40
  "@types/gulp-newer": "latest",
41
- "@types/gulp-rename": "0.0.33",
42
- "@types/gulp-sourcemaps": "0.0.32",
41
+ "@types/gulp-rename": "latest",
42
+ "@types/gulp-sourcemaps": "latest",
43
43
  "@types/merge2": "latest",
44
44
  "@types/microsoft__typescript-etw": "latest",
45
45
  "@types/minimatch": "latest",
@@ -48,29 +48,28 @@
48
48
  "@types/mocha": "latest",
49
49
  "@types/ms": "latest",
50
50
  "@types/node": "latest",
51
- "@types/node-fetch": "^2.3.4",
52
51
  "@types/q": "latest",
53
52
  "@types/source-map-support": "latest",
54
- "@types/xml2js": "^0.4.0",
55
- "@typescript-eslint/eslint-plugin": "^4.28.0",
56
- "@typescript-eslint/experimental-utils": "^4.28.0",
57
- "@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",
58
57
  "async": "latest",
59
- "azure-devops-node-api": "^11.0.1",
58
+ "azure-devops-node-api": "^11.1.1",
60
59
  "chai": "latest",
61
60
  "chalk": "^4.1.2",
62
61
  "convert-source-map": "latest",
63
- "del": "5.1.0",
64
- "diff": "^4.0.2",
65
- "eslint": "7.12.1",
66
- "eslint-formatter-autolinkable-stylish": "1.1.4",
67
- "eslint-plugin-import": "2.22.1",
68
- "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",
69
68
  "eslint-plugin-no-null": "1.0.2",
70
69
  "fancy-log": "latest",
71
- "fs-extra": "^9.0.0",
70
+ "fs-extra": "^9.1.0",
72
71
  "glob": "latest",
73
- "gulp": "^4.0.0",
72
+ "gulp": "^4.0.2",
74
73
  "gulp-concat": "latest",
75
74
  "gulp-insert": "latest",
76
75
  "gulp-newer": "latest",
@@ -82,14 +81,14 @@
82
81
  "mocha": "latest",
83
82
  "mocha-fivemat-progress-reporter": "latest",
84
83
  "ms": "^2.1.3",
85
- "node-fetch": "^2.6.1",
86
- "prex": "^0.4.3",
84
+ "node-fetch": "^3.2.6",
85
+ "prex": "^0.4.7",
87
86
  "q": "latest",
88
87
  "source-map-support": "latest",
89
88
  "typescript": "^4.5.5",
90
89
  "vinyl": "latest",
91
90
  "vinyl-sourcemaps-apply": "latest",
92
- "xml2js": "^0.4.19"
91
+ "xml2js": "^0.4.23"
93
92
  },
94
93
  "scripts": {
95
94
  "prepare": "gulp build-eslint-rules",