typescript 4.6.0-dev.20211214 → 4.6.0-dev.20211215

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.6";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20211214";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20211215";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  function tryGetNativeMap() {
@@ -27016,7 +27016,7 @@ var ts;
27016
27016
  return true;
27017
27017
  }
27018
27018
  }
27019
- else if (third === 27) {
27019
+ else if (third === 27 || third === 63) {
27020
27020
  return true;
27021
27021
  }
27022
27022
  return false;
@@ -47518,8 +47518,14 @@ var ts;
47518
47518
  }
47519
47519
  return type;
47520
47520
  }
47521
+ function isMappedTypeGenericIndexedAccess(type) {
47522
+ return type.flags & 8388608 && ts.getObjectFlags(type.objectType) & 32 &&
47523
+ !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
47524
+ }
47521
47525
  function getApparentType(type) {
47522
- var t = type.flags & 465829888 ? getBaseConstraintOfType(type) || unknownType : type;
47526
+ var t = !(type.flags & 465829888) ? type :
47527
+ isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
47528
+ getBaseConstraintOfType(type) || unknownType;
47523
47529
  return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) :
47524
47530
  t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) :
47525
47531
  t.flags & 402653316 ? globalStringType :
@@ -55554,12 +55560,14 @@ var ts;
55554
55560
  target = getActualTypeVariable(target);
55555
55561
  }
55556
55562
  if (target.flags & 8650752) {
55557
- if (ts.getObjectFlags(source) & 524288 || source === nonInferrableAnyType || source === silentNeverType ||
55558
- (priority & 128 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
55563
+ if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
55559
55564
  return;
55560
55565
  }
55561
55566
  var inference = getInferenceInfoForType(target);
55562
55567
  if (inference) {
55568
+ if (ts.getObjectFlags(source) & 524288) {
55569
+ return;
55570
+ }
55563
55571
  if (!inference.isFixed) {
55564
55572
  if (inference.priority === undefined || priority < inference.priority) {
55565
55573
  inference.candidates = undefined;
@@ -55588,18 +55596,16 @@ var ts;
55588
55596
  inferencePriority = Math.min(inferencePriority, priority);
55589
55597
  return;
55590
55598
  }
55591
- else {
55592
- var simplified = getSimplifiedType(target, false);
55593
- if (simplified !== target) {
55594
- invokeOnce(source, simplified, inferFromTypes);
55595
- }
55596
- else if (target.flags & 8388608) {
55597
- var indexType = getSimplifiedType(target.indexType, false);
55598
- if (indexType.flags & 465829888) {
55599
- var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
55600
- if (simplified_1 && simplified_1 !== target) {
55601
- invokeOnce(source, simplified_1, inferFromTypes);
55602
- }
55599
+ var simplified = getSimplifiedType(target, false);
55600
+ if (simplified !== target) {
55601
+ inferFromTypes(source, simplified);
55602
+ }
55603
+ else if (target.flags & 8388608) {
55604
+ var indexType = getSimplifiedType(target.indexType, false);
55605
+ if (indexType.flags & 465829888) {
55606
+ var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
55607
+ if (simplified_1 && simplified_1 !== target) {
55608
+ inferFromTypes(source, simplified_1);
55603
55609
  }
55604
55610
  }
55605
55611
  }
@@ -58116,7 +58122,7 @@ var ts;
58116
58122
  var substituteConstraints = !(checkMode && checkMode & 2) &&
58117
58123
  someType(type, isGenericTypeWithUnionConstraint) &&
58118
58124
  (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
58119
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 ? getBaseConstraintOrType(t) : t; }) : type;
58125
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
58120
58126
  }
58121
58127
  function isExportOrExportExpression(location) {
58122
58128
  return !!ts.findAncestor(location, function (n) {
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20211214";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20211215";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -33531,7 +33531,7 @@ var ts;
33531
33531
  return true;
33532
33532
  }
33533
33533
  }
33534
- else if (third === 27 /* CommaToken */) {
33534
+ else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) {
33535
33535
  return true;
33536
33536
  }
33537
33537
  return false;
@@ -57425,13 +57425,23 @@ var ts;
57425
57425
  }
57426
57426
  return type;
57427
57427
  }
57428
+ function isMappedTypeGenericIndexedAccess(type) {
57429
+ return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
57430
+ !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
57431
+ }
57428
57432
  /**
57429
57433
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
57430
57434
  * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
57431
57435
  * type itself.
57432
57436
  */
57433
57437
  function getApparentType(type) {
57434
- var t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
57438
+ // We obtain the base constraint for all instantiable types, except indexed access types of the form
57439
+ // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57440
+ // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57441
+ // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57442
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57443
+ isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57444
+ getBaseConstraintOfType(type) || unknownType;
57435
57445
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57436
57446
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57437
57447
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -66616,12 +66626,14 @@ var ts;
66616
66626
  // not contain anyFunctionType when we come back to this argument for its second round
66617
66627
  // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
66618
66628
  // when constructing types from type parameters that had no inference candidates).
66619
- if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType ||
66620
- (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66629
+ if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66621
66630
  return;
66622
66631
  }
66623
66632
  var inference = getInferenceInfoForType(target);
66624
66633
  if (inference) {
66634
+ if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */) {
66635
+ return;
66636
+ }
66625
66637
  if (!inference.isFixed) {
66626
66638
  if (inference.priority === undefined || priority < inference.priority) {
66627
66639
  inference.candidates = undefined;
@@ -66652,21 +66664,19 @@ var ts;
66652
66664
  inferencePriority = Math.min(inferencePriority, priority);
66653
66665
  return;
66654
66666
  }
66655
- else {
66656
- // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66657
- var simplified = getSimplifiedType(target, /*writing*/ false);
66658
- if (simplified !== target) {
66659
- invokeOnce(source, simplified, inferFromTypes);
66660
- }
66661
- else if (target.flags & 8388608 /* IndexedAccess */) {
66662
- var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66663
- // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66664
- // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66665
- if (indexType.flags & 465829888 /* Instantiable */) {
66666
- var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66667
- if (simplified_1 && simplified_1 !== target) {
66668
- invokeOnce(source, simplified_1, inferFromTypes);
66669
- }
66667
+ // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66668
+ var simplified = getSimplifiedType(target, /*writing*/ false);
66669
+ if (simplified !== target) {
66670
+ inferFromTypes(source, simplified);
66671
+ }
66672
+ else if (target.flags & 8388608 /* IndexedAccess */) {
66673
+ var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66674
+ // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66675
+ // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66676
+ if (indexType.flags & 465829888 /* Instantiable */) {
66677
+ var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66678
+ if (simplified_1 && simplified_1 !== target) {
66679
+ inferFromTypes(source, simplified_1);
66670
66680
  }
66671
66681
  }
66672
66682
  }
@@ -69536,7 +69546,7 @@ var ts;
69536
69546
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69537
69547
  someType(type, isGenericTypeWithUnionConstraint) &&
69538
69548
  (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
69539
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
69549
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69540
69550
  }
69541
69551
  function isExportOrExportExpression(location) {
69542
69552
  return !!ts.findAncestor(location, function (n) {
@@ -123110,13 +123120,6 @@ var ts;
123110
123120
  || ts.isImportSpecifier(parent)
123111
123121
  || ts.isImportClause(parent)
123112
123122
  || ts.isImportEqualsDeclaration(parent) && node === parent.name) {
123113
- var decl = parent;
123114
- while (decl) {
123115
- if (ts.isImportEqualsDeclaration(decl) || ts.isImportClause(decl) || ts.isExportDeclaration(decl)) {
123116
- return decl.isTypeOnly ? 2 /* Type */ : 7 /* All */;
123117
- }
123118
- decl = decl.parent;
123119
- }
123120
123123
  return 7 /* All */;
123121
123124
  }
123122
123125
  else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {
@@ -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.20211214";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211215";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -33725,7 +33725,7 @@ var ts;
33725
33725
  return true;
33726
33726
  }
33727
33727
  }
33728
- else if (third === 27 /* CommaToken */) {
33728
+ else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) {
33729
33729
  return true;
33730
33730
  }
33731
33731
  return false;
@@ -57619,13 +57619,23 @@ var ts;
57619
57619
  }
57620
57620
  return type;
57621
57621
  }
57622
+ function isMappedTypeGenericIndexedAccess(type) {
57623
+ return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
57624
+ !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
57625
+ }
57622
57626
  /**
57623
57627
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
57624
57628
  * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
57625
57629
  * type itself.
57626
57630
  */
57627
57631
  function getApparentType(type) {
57628
- var t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
57632
+ // We obtain the base constraint for all instantiable types, except indexed access types of the form
57633
+ // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57634
+ // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57635
+ // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57636
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57637
+ isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57638
+ getBaseConstraintOfType(type) || unknownType;
57629
57639
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57630
57640
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57631
57641
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -66810,12 +66820,14 @@ var ts;
66810
66820
  // not contain anyFunctionType when we come back to this argument for its second round
66811
66821
  // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
66812
66822
  // when constructing types from type parameters that had no inference candidates).
66813
- if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType ||
66814
- (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66823
+ if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66815
66824
  return;
66816
66825
  }
66817
66826
  var inference = getInferenceInfoForType(target);
66818
66827
  if (inference) {
66828
+ if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */) {
66829
+ return;
66830
+ }
66819
66831
  if (!inference.isFixed) {
66820
66832
  if (inference.priority === undefined || priority < inference.priority) {
66821
66833
  inference.candidates = undefined;
@@ -66846,21 +66858,19 @@ var ts;
66846
66858
  inferencePriority = Math.min(inferencePriority, priority);
66847
66859
  return;
66848
66860
  }
66849
- else {
66850
- // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66851
- var simplified = getSimplifiedType(target, /*writing*/ false);
66852
- if (simplified !== target) {
66853
- invokeOnce(source, simplified, inferFromTypes);
66854
- }
66855
- else if (target.flags & 8388608 /* IndexedAccess */) {
66856
- var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66857
- // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66858
- // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66859
- if (indexType.flags & 465829888 /* Instantiable */) {
66860
- var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66861
- if (simplified_1 && simplified_1 !== target) {
66862
- invokeOnce(source, simplified_1, inferFromTypes);
66863
- }
66861
+ // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66862
+ var simplified = getSimplifiedType(target, /*writing*/ false);
66863
+ if (simplified !== target) {
66864
+ inferFromTypes(source, simplified);
66865
+ }
66866
+ else if (target.flags & 8388608 /* IndexedAccess */) {
66867
+ var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66868
+ // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66869
+ // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66870
+ if (indexType.flags & 465829888 /* Instantiable */) {
66871
+ var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66872
+ if (simplified_1 && simplified_1 !== target) {
66873
+ inferFromTypes(source, simplified_1);
66864
66874
  }
66865
66875
  }
66866
66876
  }
@@ -69730,7 +69740,7 @@ var ts;
69730
69740
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69731
69741
  someType(type, isGenericTypeWithUnionConstraint) &&
69732
69742
  (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
69733
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
69743
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69734
69744
  }
69735
69745
  function isExportOrExportExpression(location) {
69736
69746
  return !!ts.findAncestor(location, function (n) {
@@ -123692,13 +123702,6 @@ var ts;
123692
123702
  || ts.isImportSpecifier(parent)
123693
123703
  || ts.isImportClause(parent)
123694
123704
  || ts.isImportEqualsDeclaration(parent) && node === parent.name) {
123695
- var decl = parent;
123696
- while (decl) {
123697
- if (ts.isImportEqualsDeclaration(decl) || ts.isImportClause(decl) || ts.isExportDeclaration(decl)) {
123698
- return decl.isTypeOnly ? 2 /* Type */ : 7 /* All */;
123699
- }
123700
- decl = decl.parent;
123701
- }
123702
123705
  return 7 /* All */;
123703
123706
  }
123704
123707
  else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {
package/lib/typescript.js CHANGED
@@ -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.20211214";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211215";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -33725,7 +33725,7 @@ var ts;
33725
33725
  return true;
33726
33726
  }
33727
33727
  }
33728
- else if (third === 27 /* CommaToken */) {
33728
+ else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) {
33729
33729
  return true;
33730
33730
  }
33731
33731
  return false;
@@ -57619,13 +57619,23 @@ var ts;
57619
57619
  }
57620
57620
  return type;
57621
57621
  }
57622
+ function isMappedTypeGenericIndexedAccess(type) {
57623
+ return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
57624
+ !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
57625
+ }
57622
57626
  /**
57623
57627
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
57624
57628
  * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
57625
57629
  * type itself.
57626
57630
  */
57627
57631
  function getApparentType(type) {
57628
- var t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
57632
+ // We obtain the base constraint for all instantiable types, except indexed access types of the form
57633
+ // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57634
+ // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57635
+ // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57636
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57637
+ isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57638
+ getBaseConstraintOfType(type) || unknownType;
57629
57639
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57630
57640
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57631
57641
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -66810,12 +66820,14 @@ var ts;
66810
66820
  // not contain anyFunctionType when we come back to this argument for its second round
66811
66821
  // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
66812
66822
  // when constructing types from type parameters that had no inference candidates).
66813
- if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType ||
66814
- (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66823
+ if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66815
66824
  return;
66816
66825
  }
66817
66826
  var inference = getInferenceInfoForType(target);
66818
66827
  if (inference) {
66828
+ if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */) {
66829
+ return;
66830
+ }
66819
66831
  if (!inference.isFixed) {
66820
66832
  if (inference.priority === undefined || priority < inference.priority) {
66821
66833
  inference.candidates = undefined;
@@ -66846,21 +66858,19 @@ var ts;
66846
66858
  inferencePriority = Math.min(inferencePriority, priority);
66847
66859
  return;
66848
66860
  }
66849
- else {
66850
- // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66851
- var simplified = getSimplifiedType(target, /*writing*/ false);
66852
- if (simplified !== target) {
66853
- invokeOnce(source, simplified, inferFromTypes);
66854
- }
66855
- else if (target.flags & 8388608 /* IndexedAccess */) {
66856
- var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66857
- // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66858
- // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66859
- if (indexType.flags & 465829888 /* Instantiable */) {
66860
- var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66861
- if (simplified_1 && simplified_1 !== target) {
66862
- invokeOnce(source, simplified_1, inferFromTypes);
66863
- }
66861
+ // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66862
+ var simplified = getSimplifiedType(target, /*writing*/ false);
66863
+ if (simplified !== target) {
66864
+ inferFromTypes(source, simplified);
66865
+ }
66866
+ else if (target.flags & 8388608 /* IndexedAccess */) {
66867
+ var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66868
+ // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66869
+ // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66870
+ if (indexType.flags & 465829888 /* Instantiable */) {
66871
+ var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66872
+ if (simplified_1 && simplified_1 !== target) {
66873
+ inferFromTypes(source, simplified_1);
66864
66874
  }
66865
66875
  }
66866
66876
  }
@@ -69730,7 +69740,7 @@ var ts;
69730
69740
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69731
69741
  someType(type, isGenericTypeWithUnionConstraint) &&
69732
69742
  (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
69733
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
69743
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69734
69744
  }
69735
69745
  function isExportOrExportExpression(location) {
69736
69746
  return !!ts.findAncestor(location, function (n) {
@@ -123692,13 +123702,6 @@ var ts;
123692
123702
  || ts.isImportSpecifier(parent)
123693
123703
  || ts.isImportClause(parent)
123694
123704
  || ts.isImportEqualsDeclaration(parent) && node === parent.name) {
123695
- var decl = parent;
123696
- while (decl) {
123697
- if (ts.isImportEqualsDeclaration(decl) || ts.isImportClause(decl) || ts.isExportDeclaration(decl)) {
123698
- return decl.isTypeOnly ? 2 /* Type */ : 7 /* All */;
123699
- }
123700
- decl = decl.parent;
123701
- }
123702
123705
  return 7 /* All */;
123703
123706
  }
123704
123707
  else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {
@@ -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.20211214";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211215";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -33725,7 +33725,7 @@ var ts;
33725
33725
  return true;
33726
33726
  }
33727
33727
  }
33728
- else if (third === 27 /* CommaToken */) {
33728
+ else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) {
33729
33729
  return true;
33730
33730
  }
33731
33731
  return false;
@@ -57619,13 +57619,23 @@ var ts;
57619
57619
  }
57620
57620
  return type;
57621
57621
  }
57622
+ function isMappedTypeGenericIndexedAccess(type) {
57623
+ return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
57624
+ !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
57625
+ }
57622
57626
  /**
57623
57627
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
57624
57628
  * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
57625
57629
  * type itself.
57626
57630
  */
57627
57631
  function getApparentType(type) {
57628
- var t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
57632
+ // We obtain the base constraint for all instantiable types, except indexed access types of the form
57633
+ // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57634
+ // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57635
+ // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57636
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57637
+ isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57638
+ getBaseConstraintOfType(type) || unknownType;
57629
57639
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57630
57640
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57631
57641
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -66810,12 +66820,14 @@ var ts;
66810
66820
  // not contain anyFunctionType when we come back to this argument for its second round
66811
66821
  // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
66812
66822
  // when constructing types from type parameters that had no inference candidates).
66813
- if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType ||
66814
- (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66823
+ if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66815
66824
  return;
66816
66825
  }
66817
66826
  var inference = getInferenceInfoForType(target);
66818
66827
  if (inference) {
66828
+ if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */) {
66829
+ return;
66830
+ }
66819
66831
  if (!inference.isFixed) {
66820
66832
  if (inference.priority === undefined || priority < inference.priority) {
66821
66833
  inference.candidates = undefined;
@@ -66846,21 +66858,19 @@ var ts;
66846
66858
  inferencePriority = Math.min(inferencePriority, priority);
66847
66859
  return;
66848
66860
  }
66849
- else {
66850
- // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66851
- var simplified = getSimplifiedType(target, /*writing*/ false);
66852
- if (simplified !== target) {
66853
- invokeOnce(source, simplified, inferFromTypes);
66854
- }
66855
- else if (target.flags & 8388608 /* IndexedAccess */) {
66856
- var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66857
- // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66858
- // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66859
- if (indexType.flags & 465829888 /* Instantiable */) {
66860
- var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66861
- if (simplified_1 && simplified_1 !== target) {
66862
- invokeOnce(source, simplified_1, inferFromTypes);
66863
- }
66861
+ // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66862
+ var simplified = getSimplifiedType(target, /*writing*/ false);
66863
+ if (simplified !== target) {
66864
+ inferFromTypes(source, simplified);
66865
+ }
66866
+ else if (target.flags & 8388608 /* IndexedAccess */) {
66867
+ var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66868
+ // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66869
+ // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66870
+ if (indexType.flags & 465829888 /* Instantiable */) {
66871
+ var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66872
+ if (simplified_1 && simplified_1 !== target) {
66873
+ inferFromTypes(source, simplified_1);
66864
66874
  }
66865
66875
  }
66866
66876
  }
@@ -69730,7 +69740,7 @@ var ts;
69730
69740
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69731
69741
  someType(type, isGenericTypeWithUnionConstraint) &&
69732
69742
  (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
69733
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
69743
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69734
69744
  }
69735
69745
  function isExportOrExportExpression(location) {
69736
69746
  return !!ts.findAncestor(location, function (n) {
@@ -123692,13 +123702,6 @@ var ts;
123692
123702
  || ts.isImportSpecifier(parent)
123693
123703
  || ts.isImportClause(parent)
123694
123704
  || ts.isImportEqualsDeclaration(parent) && node === parent.name) {
123695
- var decl = parent;
123696
- while (decl) {
123697
- if (ts.isImportEqualsDeclaration(decl) || ts.isImportClause(decl) || ts.isExportDeclaration(decl)) {
123698
- return decl.isTypeOnly ? 2 /* Type */ : 7 /* All */;
123699
- }
123700
- decl = decl.parent;
123701
- }
123702
123705
  return 7 /* All */;
123703
123706
  }
123704
123707
  else if (isInRightSideOfInternalImportEqualsDeclaration(node)) {
@@ -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.20211214";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20211215";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -33520,7 +33520,7 @@ var ts;
33520
33520
  return true;
33521
33521
  }
33522
33522
  }
33523
- else if (third === 27 /* CommaToken */) {
33523
+ else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) {
33524
33524
  return true;
33525
33525
  }
33526
33526
  return false;
@@ -57414,13 +57414,23 @@ var ts;
57414
57414
  }
57415
57415
  return type;
57416
57416
  }
57417
+ function isMappedTypeGenericIndexedAccess(type) {
57418
+ return type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(type.objectType) & 32 /* Mapped */ &&
57419
+ !isGenericMappedType(type.objectType) && isGenericIndexType(type.indexType);
57420
+ }
57417
57421
  /**
57418
57422
  * For a type parameter, return the base constraint of the type parameter. For the string, number,
57419
57423
  * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the
57420
57424
  * type itself.
57421
57425
  */
57422
57426
  function getApparentType(type) {
57423
- var t = type.flags & 465829888 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type;
57427
+ // We obtain the base constraint for all instantiable types, except indexed access types of the form
57428
+ // { [P in K]: E }[X], where K is non-generic and X is generic. For those types, we instead substitute an
57429
+ // instantiation of E where P is replaced with X. We do this because getBaseConstraintOfType directly
57430
+ // lowers to an instantiation where X's constraint is substituted for X, which isn't always desirable.
57431
+ var t = !(type.flags & 465829888 /* Instantiable */) ? type :
57432
+ isMappedTypeGenericIndexedAccess(type) ? substituteIndexedMappedType(type.objectType, type.indexType) :
57433
+ getBaseConstraintOfType(type) || unknownType;
57424
57434
  return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) :
57425
57435
  t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) :
57426
57436
  t.flags & 402653316 /* StringLike */ ? globalStringType :
@@ -66605,12 +66615,14 @@ var ts;
66605
66615
  // not contain anyFunctionType when we come back to this argument for its second round
66606
66616
  // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
66607
66617
  // when constructing types from type parameters that had no inference candidates).
66608
- if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType ||
66609
- (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66618
+ if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
66610
66619
  return;
66611
66620
  }
66612
66621
  var inference = getInferenceInfoForType(target);
66613
66622
  if (inference) {
66623
+ if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */) {
66624
+ return;
66625
+ }
66614
66626
  if (!inference.isFixed) {
66615
66627
  if (inference.priority === undefined || priority < inference.priority) {
66616
66628
  inference.candidates = undefined;
@@ -66641,21 +66653,19 @@ var ts;
66641
66653
  inferencePriority = Math.min(inferencePriority, priority);
66642
66654
  return;
66643
66655
  }
66644
- else {
66645
- // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66646
- var simplified = getSimplifiedType(target, /*writing*/ false);
66647
- if (simplified !== target) {
66648
- invokeOnce(source, simplified, inferFromTypes);
66649
- }
66650
- else if (target.flags & 8388608 /* IndexedAccess */) {
66651
- var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66652
- // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66653
- // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66654
- if (indexType.flags & 465829888 /* Instantiable */) {
66655
- var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66656
- if (simplified_1 && simplified_1 !== target) {
66657
- invokeOnce(source, simplified_1, inferFromTypes);
66658
- }
66656
+ // Infer to the simplified version of an indexed access, if possible, to (hopefully) expose more bare type parameters to the inference engine
66657
+ var simplified = getSimplifiedType(target, /*writing*/ false);
66658
+ if (simplified !== target) {
66659
+ inferFromTypes(source, simplified);
66660
+ }
66661
+ else if (target.flags & 8388608 /* IndexedAccess */) {
66662
+ var indexType = getSimplifiedType(target.indexType, /*writing*/ false);
66663
+ // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider
66664
+ // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can.
66665
+ if (indexType.flags & 465829888 /* Instantiable */) {
66666
+ var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false);
66667
+ if (simplified_1 && simplified_1 !== target) {
66668
+ inferFromTypes(source, simplified_1);
66659
66669
  }
66660
66670
  }
66661
66671
  }
@@ -69525,7 +69535,7 @@ var ts;
69525
69535
  var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) &&
69526
69536
  someType(type, isGenericTypeWithUnionConstraint) &&
69527
69537
  (isConstraintPosition(type, reference) || hasNonBindingPatternContextualTypeWithNoGenericTypes(reference));
69528
- return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type;
69538
+ return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ && !isMappedTypeGenericIndexedAccess(t) ? getBaseConstraintOrType(t) : t; }) : type;
69529
69539
  }
69530
69540
  function isExportOrExportExpression(location) {
69531
69541
  return !!ts.findAncestor(location, function (n) {
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.6.0-dev.20211214",
5
+ "version": "4.6.0-dev.20211215",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [