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.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.8";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220616";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220617";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -6831,6 +6831,8 @@ var ts;
6831
6831
  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}'."),
6832
6832
  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."),
6833
6833
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
6834
+ 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."),
6835
+ 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."),
6834
6836
  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."),
6835
6837
  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."),
6836
6838
  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'."),
@@ -40065,9 +40067,9 @@ var ts;
40065
40067
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true);
40066
40068
  },
40067
40069
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
40068
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
40070
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
40069
40071
  var node = ts.getParseTreeNode(nodeIn);
40070
- return node && tryGetThisTypeAt(node, includeGlobalThis);
40072
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
40071
40073
  },
40072
40074
  getTypeArgumentConstraint: function (nodeIn) {
40073
40075
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -49167,7 +49169,7 @@ var ts;
49167
49169
  }
49168
49170
  if (t.flags & 268435456) {
49169
49171
  var constraint = getBaseConstraint(t.type);
49170
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
49172
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
49171
49173
  }
49172
49174
  if (t.flags & 8388608) {
49173
49175
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -51798,9 +51800,11 @@ var ts;
51798
51800
  }
51799
51801
  function getStringMappingType(symbol, type) {
51800
51802
  return type.flags & (1048576 | 131072) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
51801
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
51802
- type.flags & 128 ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
51803
- type;
51803
+ type.flags & 268435456 && symbol === type.symbol ? type :
51804
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456) ? getTemplateLiteralType(["", ""], [type]) : type) :
51805
+ type.flags & 128 ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
51806
+ type.flags & 134217728 ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
51807
+ type;
51804
51808
  }
51805
51809
  function applyStringMapping(symbol, str) {
51806
51810
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -51811,6 +51815,15 @@ var ts;
51811
51815
  }
51812
51816
  return str;
51813
51817
  }
51818
+ function applyTemplateStringMapping(symbol, texts, types) {
51819
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
51820
+ case 0: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
51821
+ case 1: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
51822
+ case 2: 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];
51823
+ case 3: 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];
51824
+ }
51825
+ return [texts, types];
51826
+ }
51814
51827
  function getStringMappingTypeForGenericType(symbol, type) {
51815
51828
  var id = getSymbolId(symbol) + "," + getTypeId(type);
51816
51829
  var result = stringMappingTypes.get(id);
@@ -52040,7 +52053,7 @@ var ts;
52040
52053
  accessNode;
52041
52054
  }
52042
52055
  function isPatternLiteralPlaceholderType(type) {
52043
- return !!(type.flags & (1 | 4 | 8 | 64));
52056
+ return !!(type.flags & (1 | 4 | 8 | 64)) || !!(type.flags & 268435456 && isPatternLiteralPlaceholderType(type.type));
52044
52057
  }
52045
52058
  function isPatternLiteralType(type) {
52046
52059
  return !!(type.flags & 134217728) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -55262,6 +55275,13 @@ var ts;
55262
55275
  return -1;
55263
55276
  }
55264
55277
  }
55278
+ else if (target.flags & 268435456) {
55279
+ if (!(source.flags & 268435456)) {
55280
+ if (isMemberOfStringMapping(source, target)) {
55281
+ return -1;
55282
+ }
55283
+ }
55284
+ }
55265
55285
  if (sourceFlags & 8650752) {
55266
55286
  if (!(sourceFlags & 8388608 && targetFlags & 8388608)) {
55267
55287
  var constraint = getConstraintOfType(source) || unknownType;
@@ -55300,7 +55320,10 @@ var ts;
55300
55320
  }
55301
55321
  }
55302
55322
  else if (sourceFlags & 268435456) {
55303
- if (targetFlags & 268435456 && source.symbol === target.symbol) {
55323
+ if (targetFlags & 268435456) {
55324
+ if (source.symbol !== target.symbol) {
55325
+ return 0;
55326
+ }
55304
55327
  if (result = isRelatedTo(source.type, target.type, 3, reportErrors)) {
55305
55328
  resetErrorInfo(saveErrorInfo);
55306
55329
  return result;
@@ -56096,7 +56119,7 @@ var ts;
56096
56119
  return typeCouldHaveTopLevelSingletonTypes(constraint);
56097
56120
  }
56098
56121
  }
56099
- return isUnitType(type) || !!(type.flags & 134217728);
56122
+ return isUnitType(type) || !!(type.flags & 134217728) || !!(type.flags & 268435456);
56100
56123
  }
56101
56124
  function getExactOptionalUnassignableProperties(source, target) {
56102
56125
  if (isTupleType(source) && isTupleType(target))
@@ -57363,6 +57386,24 @@ var ts;
57363
57386
  return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512)
57364
57387
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
57365
57388
  }
57389
+ function isMemberOfStringMapping(source, target) {
57390
+ if (target.flags & (4 | 3)) {
57391
+ return true;
57392
+ }
57393
+ if (target.flags & 134217728) {
57394
+ return isTypeAssignableTo(source, target);
57395
+ }
57396
+ if (target.flags & 268435456) {
57397
+ var mappingStack = [];
57398
+ while (target.flags & 268435456) {
57399
+ mappingStack.unshift(target.symbol);
57400
+ target = target.type;
57401
+ }
57402
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
57403
+ return mappedSource === source && isMemberOfStringMapping(source, target);
57404
+ }
57405
+ return false;
57406
+ }
57366
57407
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
57367
57408
  if (source === target || target.flags & (1 | 4)) {
57368
57409
  return true;
@@ -57371,7 +57412,8 @@ var ts;
57371
57412
  var value = source.value;
57372
57413
  return !!(target.flags & 8 && isValidNumberString(value, false) ||
57373
57414
  target.flags & 64 && isValidBigIntString(value, false) ||
57374
- target.flags & (512 | 98304) && value === target.intrinsicName);
57415
+ target.flags & (512 | 98304) && value === target.intrinsicName ||
57416
+ target.flags & 268435456 && isMemberOfStringMapping(getStringLiteralType(value), target));
57375
57417
  }
57376
57418
  if (source.flags & 134217728) {
57377
57419
  var texts = source.texts;
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220616";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220617";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -9672,6 +9672,8 @@ var ts;
9672
9672
  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}'."),
9673
9673
  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."),
9674
9674
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
9675
+ 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."),
9676
+ 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."),
9675
9677
  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."),
9676
9678
  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."),
9677
9679
  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'."),
@@ -48910,9 +48912,9 @@ var ts;
48910
48912
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
48911
48913
  },
48912
48914
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
48913
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
48915
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
48914
48916
  var node = ts.getParseTreeNode(nodeIn);
48915
- return node && tryGetThisTypeAt(node, includeGlobalThis);
48917
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
48916
48918
  },
48917
48919
  getTypeArgumentConstraint: function (nodeIn) {
48918
48920
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -59360,7 +59362,7 @@ var ts;
59360
59362
  }
59361
59363
  if (t.flags & 268435456 /* StringMapping */) {
59362
59364
  var constraint = getBaseConstraint(t.type);
59363
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59365
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59364
59366
  }
59365
59367
  if (t.flags & 8388608 /* IndexedAccess */) {
59366
59368
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62330,9 +62332,12 @@ var ts;
62330
62332
  }
62331
62333
  function getStringMappingType(symbol, type) {
62332
62334
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62333
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62334
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62335
- type;
62335
+ // Mapping<Mapping<T>> === Mapping<T>
62336
+ type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
62337
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
62338
+ type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62339
+ type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
62340
+ type;
62336
62341
  }
62337
62342
  function applyStringMapping(symbol, str) {
62338
62343
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62343,6 +62348,15 @@ var ts;
62343
62348
  }
62344
62349
  return str;
62345
62350
  }
62351
+ function applyTemplateStringMapping(symbol, texts, types) {
62352
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
62353
+ case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62354
+ case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62355
+ 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];
62356
+ 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];
62357
+ }
62358
+ return [texts, types];
62359
+ }
62346
62360
  function getStringMappingTypeForGenericType(symbol, type) {
62347
62361
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62348
62362
  var result = stringMappingTypes.get(id);
@@ -62584,7 +62598,7 @@ var ts;
62584
62598
  accessNode;
62585
62599
  }
62586
62600
  function isPatternLiteralPlaceholderType(type) {
62587
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
62601
+ return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
62588
62602
  }
62589
62603
  function isPatternLiteralType(type) {
62590
62604
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -66296,6 +66310,13 @@ var ts;
66296
66310
  return -1 /* True */;
66297
66311
  }
66298
66312
  }
66313
+ else if (target.flags & 268435456 /* StringMapping */) {
66314
+ if (!(source.flags & 268435456 /* StringMapping */)) {
66315
+ if (isMemberOfStringMapping(source, target)) {
66316
+ return -1 /* True */;
66317
+ }
66318
+ }
66319
+ }
66299
66320
  if (sourceFlags & 8650752 /* TypeVariable */) {
66300
66321
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66301
66322
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66339,7 +66360,10 @@ var ts;
66339
66360
  }
66340
66361
  }
66341
66362
  else if (sourceFlags & 268435456 /* StringMapping */) {
66342
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66363
+ if (targetFlags & 268435456 /* StringMapping */) {
66364
+ if (source.symbol !== target.symbol) {
66365
+ return 0 /* False */;
66366
+ }
66343
66367
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66344
66368
  resetErrorInfo(saveErrorInfo);
66345
66369
  return result;
@@ -67264,7 +67288,7 @@ var ts;
67264
67288
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67265
67289
  }
67266
67290
  }
67267
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67291
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67268
67292
  }
67269
67293
  function getExactOptionalUnassignableProperties(source, target) {
67270
67294
  if (isTupleType(source) && isTupleType(target))
@@ -68735,6 +68759,31 @@ var ts;
68735
68759
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68736
68760
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68737
68761
  }
68762
+ function isMemberOfStringMapping(source, target) {
68763
+ if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
68764
+ return true;
68765
+ }
68766
+ if (target.flags & 134217728 /* TemplateLiteral */) {
68767
+ return isTypeAssignableTo(source, target);
68768
+ }
68769
+ if (target.flags & 268435456 /* StringMapping */) {
68770
+ // We need to see whether applying the same mappings of the target
68771
+ // onto the source would produce an identical type *and* that
68772
+ // it's compatible with the inner-most non-string-mapped type.
68773
+ //
68774
+ // The intuition here is that if same mappings don't affect the source at all,
68775
+ // and the source is compatible with the unmapped target, then they must
68776
+ // still reside in the same domain.
68777
+ var mappingStack = [];
68778
+ while (target.flags & 268435456 /* StringMapping */) {
68779
+ mappingStack.unshift(target.symbol);
68780
+ target = target.type;
68781
+ }
68782
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
68783
+ return mappedSource === source && isMemberOfStringMapping(source, target);
68784
+ }
68785
+ return false;
68786
+ }
68738
68787
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68739
68788
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68740
68789
  return true;
@@ -68743,7 +68792,8 @@ var ts;
68743
68792
  var value = source.value;
68744
68793
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68745
68794
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68746
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68795
+ target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
68796
+ target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68747
68797
  }
68748
68798
  if (source.flags & 134217728 /* TemplateLiteral */) {
68749
68799
  var texts = source.texts;
@@ -134782,7 +134832,7 @@ var ts;
134782
134832
  }
134783
134833
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
134784
134834
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
134785
- var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
134835
+ var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
134786
134836
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
134787
134837
  for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
134788
134838
  var symbol = _a[_i];
@@ -144120,10 +144170,10 @@ var ts;
144120
144170
  (function (ts) {
144121
144171
  var Rename;
144122
144172
  (function (Rename) {
144123
- function getRenameInfo(program, sourceFile, position, options) {
144173
+ function getRenameInfo(program, sourceFile, position, preferences) {
144124
144174
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
144125
144175
  if (nodeIsEligibleForRename(node)) {
144126
- var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options);
144176
+ var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
144127
144177
  if (renameInfo) {
144128
144178
  return renameInfo;
144129
144179
  }
@@ -144131,7 +144181,7 @@ var ts;
144131
144181
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
144132
144182
  }
144133
144183
  Rename.getRenameInfo = getRenameInfo;
144134
- function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) {
144184
+ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
144135
144185
  var symbol = typeChecker.getSymbolAtLocation(node);
144136
144186
  if (!symbol) {
144137
144187
  if (ts.isStringLiteralLike(node)) {
@@ -144159,7 +144209,12 @@ var ts;
144159
144209
  return undefined;
144160
144210
  }
144161
144211
  if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
144162
- return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144212
+ return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144213
+ }
144214
+ // Disallow rename for elements that would rename across `*/node_modules/*` packages.
144215
+ var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
144216
+ if (wouldRenameNodeModules) {
144217
+ return getRenameInfoError(wouldRenameNodeModules);
144163
144218
  }
144164
144219
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
144165
144220
  var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
@@ -144173,6 +144228,49 @@ var ts;
144173
144228
  var sourceFile = declaration.getSourceFile();
144174
144229
  return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
144175
144230
  }
144231
+ function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
144232
+ if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
144233
+ var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
144234
+ if (importSpecifier && !importSpecifier.propertyName) {
144235
+ symbol = checker.getAliasedSymbol(symbol);
144236
+ }
144237
+ }
144238
+ var declarations = symbol.declarations;
144239
+ if (!declarations) {
144240
+ return undefined;
144241
+ }
144242
+ var originalPackage = getPackagePathComponents(originalFile.path);
144243
+ if (originalPackage === undefined) { // original source file is not in node_modules
144244
+ if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
144245
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
144246
+ }
144247
+ else {
144248
+ return undefined;
144249
+ }
144250
+ }
144251
+ // original source file is in node_modules
144252
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
144253
+ var declaration = declarations_4[_i];
144254
+ var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
144255
+ if (declPackage) {
144256
+ var length_2 = Math.min(originalPackage.length, declPackage.length);
144257
+ for (var i = 0; i <= length_2; i++) {
144258
+ if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
144259
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
144260
+ }
144261
+ }
144262
+ }
144263
+ }
144264
+ return undefined;
144265
+ }
144266
+ function getPackagePathComponents(filePath) {
144267
+ var components = ts.getPathComponents(filePath);
144268
+ var nodeModulesIdx = components.lastIndexOf("node_modules");
144269
+ if (nodeModulesIdx === -1) {
144270
+ return undefined;
144271
+ }
144272
+ return components.slice(0, nodeModulesIdx + 2);
144273
+ }
144176
144274
  function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
144177
144275
  if (!ts.isExternalModuleNameRelative(node.text)) {
144178
144276
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
@@ -161212,11 +161310,11 @@ var ts;
161212
161310
  }
161213
161311
  }
161214
161312
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
161215
- var declarations_5 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161313
+ var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161216
161314
  var numInitializers = 0;
161217
161315
  var lastInitializer = void 0;
161218
- for (var _i = 0, declarations_4 = declarations_5; _i < declarations_4.length; _i++) {
161219
- var declaration = declarations_4[_i];
161316
+ for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
161317
+ var declaration = declarations_5[_i];
161220
161318
  if (declaration.initializer) {
161221
161319
  numInitializers++;
161222
161320
  lastInitializer = declaration.initializer;
@@ -165353,8 +165451,8 @@ var ts;
165353
165451
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
165354
165452
  }
165355
165453
  };
165356
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
165357
- var declaration = declarations_6[_i];
165454
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165455
+ var declaration = declarations_7[_i];
165358
165456
  _loop_21(declaration);
165359
165457
  }
165360
165458
  }
@@ -165380,8 +165478,8 @@ var ts;
165380
165478
  if (inheritedDocs)
165381
165479
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
165382
165480
  };
165383
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165384
- var declaration = declarations_7[_i];
165481
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
165482
+ var declaration = declarations_8[_i];
165385
165483
  _loop_22(declaration);
165386
165484
  }
165387
165485
  }
@@ -166958,9 +167056,9 @@ var ts;
166958
167056
  return ts.stringContains(path, "/node_modules/");
166959
167057
  }
166960
167058
  }
166961
- function getRenameInfo(fileName, position, options) {
167059
+ function getRenameInfo(fileName, position, preferences) {
166962
167060
  synchronizeHostData();
166963
- return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options);
167061
+ return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
166964
167062
  }
166965
167063
  function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
166966
167064
  var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
@@ -168326,9 +168424,9 @@ var ts;
168326
168424
  var _this = this;
168327
168425
  return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
168328
168426
  };
168329
- LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) {
168427
+ LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
168330
168428
  var _this = this;
168331
- return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); });
168429
+ return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
168332
168430
  };
168333
168431
  LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
168334
168432
  var _this = this;
@@ -176498,7 +176596,7 @@ var ts;
176498
176596
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
176499
176597
  }
176500
176598
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
176501
- var _a;
176599
+ var _a, _b;
176502
176600
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
176503
176601
  /*isForRename*/ false, function (project, position) {
176504
176602
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -176518,7 +176616,7 @@ var ts;
176518
176616
  // have started the other project searches from related symbols. Propagate the
176519
176617
  // correct results to all other projects.
176520
176618
  var defaultProjectResults = perProjectResults.get(defaultProject);
176521
- if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
176619
+ if (((_b = (_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined) {
176522
176620
  // Clear all isDefinition properties
176523
176621
  perProjectResults.forEach(function (projectResults) {
176524
176622
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -176535,8 +176633,8 @@ var ts;
176535
176633
  var knownSymbolSpans_1 = createDocumentSpanSet();
176536
176634
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
176537
176635
  var referencedSymbol = defaultProjectResults_1[_i];
176538
- for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
176539
- var ref = _c[_b];
176636
+ for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
176637
+ var ref = _d[_c];
176540
176638
  if (ref.isDefinition) {
176541
176639
  knownSymbolSpans_1.add(ref);
176542
176640
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -176655,23 +176753,30 @@ var ts;
176655
176753
  var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
176656
176754
  defaultDefinition :
176657
176755
  defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
176658
- // Track which projects we have already searched so that we don't repeat searches.
176659
- // We store the project key, rather than the project, because that's what `loadAncestorProjectTree` wants.
176660
- // (For that same reason, we don't use `resultsMap` for this check.)
176661
- var searchedProjects = new ts.Set();
176756
+ // The keys of resultsMap allow us to check which projects have already been searched, but we also
176757
+ // maintain a set of strings because that's what `loadAncestorProjectTree` wants.
176758
+ var searchedProjectKeys = new ts.Set();
176662
176759
  onCancellation: while (queue.length) {
176663
176760
  while (queue.length) {
176664
176761
  if (cancellationToken.isCancellationRequested())
176665
176762
  break onCancellation;
176763
+ var skipCount = 0;
176764
+ for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
176765
+ ;
176766
+ if (skipCount === queue.length) {
176767
+ queue.length = 0;
176768
+ break;
176769
+ }
176770
+ if (skipCount > 0) {
176771
+ queue.splice(0, skipCount);
176772
+ }
176773
+ // NB: we may still skip if it's a project reference redirect
176666
176774
  var _a = queue.shift(), project = _a.project, location = _a.location;
176667
176775
  if (isLocationProjectReferenceRedirect(project, location))
176668
176776
  continue;
176669
- if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
176670
- continue;
176671
176777
  var projectResults = searchPosition(project, location);
176672
- if (projectResults) {
176673
- resultsMap.set(project, projectResults);
176674
- }
176778
+ resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
176779
+ searchedProjectKeys.add(getProjectKey(project));
176675
176780
  }
176676
176781
  // At this point, we know about all projects passed in as arguments and any projects in which
176677
176782
  // `getResultsForPosition` has returned results. We expand that set to include any projects
@@ -176679,11 +176784,11 @@ var ts;
176679
176784
  // containing `initialLocation`.
176680
176785
  if (defaultDefinition) {
176681
176786
  // This seems to mean "load all projects downstream from any member of `seenProjects`".
176682
- projectService.loadAncestorProjectTree(searchedProjects);
176787
+ projectService.loadAncestorProjectTree(searchedProjectKeys);
176683
176788
  projectService.forEachEnabledProject(function (project) {
176684
176789
  if (cancellationToken.isCancellationRequested())
176685
176790
  return; // There's no mechanism for skipping the remaining projects
176686
- if (searchedProjects.has(getProjectKey(project)))
176791
+ if (resultsMap.has(project))
176687
176792
  return; // Can loop forever without this (enqueue here, dequeue above, repeat)
176688
176793
  var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
176689
176794
  if (location) {
@@ -176694,9 +176799,10 @@ var ts;
176694
176799
  }
176695
176800
  // In the common case where there's only one project, return a simpler result to make
176696
176801
  // it easier for the caller to skip post-processing.
176697
- if (searchedProjects.size === 1) {
176802
+ if (resultsMap.size === 1) {
176698
176803
  var it = resultsMap.values().next();
176699
- return it.done ? server.emptyArray : it.value; // There may not be any results at all
176804
+ ts.Debug.assert(!it.done);
176805
+ return it.value;
176700
176806
  }
176701
176807
  return resultsMap;
176702
176808
  function searchPosition(project, location) {
@@ -176713,7 +176819,7 @@ var ts;
176713
176819
  var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
176714
176820
  for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
176715
176821
  var project_1 = _a[_i];
176716
- if (!project_1.isOrphan()) {
176822
+ if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
176717
176823
  queue.push({ project: project_1, location: originalLocation });
176718
176824
  }
176719
176825
  }
@@ -176722,7 +176828,7 @@ var ts;
176722
176828
  symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
176723
176829
  for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
176724
176830
  var symlinkedProject = symlinkedProjects_2[_i];
176725
- if (!symlinkedProject.isOrphan()) {
176831
+ if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
176726
176832
  queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
176727
176833
  }
176728
176834
  }
@@ -178015,7 +178121,8 @@ var ts;
178015
178121
  Session.prototype.getRenameInfo = function (args) {
178016
178122
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
178017
178123
  var position = this.getPositionInFile(args, file);
178018
- return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath });
178124
+ var preferences = this.getPreferences(file);
178125
+ return project.getLanguageService().getRenameInfo(file, position, preferences);
178019
178126
  };
178020
178127
  Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
178021
178128
  var _a;
@@ -178066,10 +178173,11 @@ var ts;
178066
178173
  var position = this.getPositionInFile(args, file);
178067
178174
  var projects = this.getProjects(args);
178068
178175
  var defaultProject = this.getDefaultProject(args);
178069
- var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178176
+ var preferences = this.getPreferences(file);
178177
+ var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178070
178178
  if (!renameInfo.canRename)
178071
178179
  return simplifiedResult ? { info: renameInfo, locs: [] } : [];
178072
- var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
178180
+ var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
178073
178181
  if (!simplifiedResult)
178074
178182
  return locations;
178075
178183
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
@@ -4137,6 +4137,7 @@ declare namespace ts {
4137
4137
  readonly includeInlayPropertyDeclarationTypeHints?: boolean;
4138
4138
  readonly includeInlayFunctionLikeReturnTypeHints?: boolean;
4139
4139
  readonly includeInlayEnumMemberValueHints?: boolean;
4140
+ readonly allowRenameOfImportPath?: boolean;
4140
4141
  }
4141
4142
  /** Represents a bigint literal value without requiring bigint support */
4142
4143
  export interface PseudoBigInt {
@@ -5917,6 +5918,8 @@ declare namespace ts {
5917
5918
  getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined;
5918
5919
  getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined;
5919
5920
  getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined;
5921
+ getRenameInfo(fileName: string, position: number, preferences: UserPreferences): RenameInfo;
5922
+ /** @deprecated Use the signature with `UserPreferences` instead. */
5920
5923
  getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo;
5921
5924
  findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined;
5922
5925
  getSmartSelectionRange(fileName: string, position: number): SelectionRange;
@@ -6296,6 +6299,7 @@ declare namespace ts {
6296
6299
  Insert = "insert",
6297
6300
  Remove = "remove"
6298
6301
  }
6302
+ /** @deprecated - consider using EditorSettings instead */
6299
6303
  interface EditorOptions {
6300
6304
  BaseIndentSize?: number;
6301
6305
  IndentSize: number;
@@ -6313,6 +6317,7 @@ declare namespace ts {
6313
6317
  indentStyle?: IndentStyle;
6314
6318
  trimTrailingWhitespace?: boolean;
6315
6319
  }
6320
+ /** @deprecated - consider using FormatCodeSettings instead */
6316
6321
  interface FormatCodeOptions extends EditorOptions {
6317
6322
  InsertSpaceAfterCommaDelimiter: boolean;
6318
6323
  InsertSpaceAfterSemicolonInForStatements: boolean;
@@ -6438,6 +6443,9 @@ declare namespace ts {
6438
6443
  canRename: false;
6439
6444
  localizedErrorMessage: string;
6440
6445
  }
6446
+ /**
6447
+ * @deprecated Use `UserPreferences` instead.
6448
+ */
6441
6449
  interface RenameInfoOptions {
6442
6450
  readonly allowRenameOfImportPath?: boolean;
6443
6451
  }