@@ -22480,18 +22480,26 @@ namespace ts {
22480
22480
target = getActualTypeVariable(target);
22481
22481
}
22482
22482
if (target.flags & TypeFlags.TypeVariable) {
22483
- // If target is a type parameter, make an inference, unless the source type contains
22484
- // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions).
22485
- // Because the anyFunctionType is internal, it should not be exposed to the user by adding
22486
- // it as an inference candidate. Hopefully, a better candidate will come along that does
22487
- // not contain anyFunctionType when we come back to this argument for its second round
22488
- // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
22489
- // when constructing types from type parameters that had no inference candidates).
22483
+ // Skip inference if the source is "blocked", which is used by the language service to
22484
+ // prevent inference on nodes currently being edited.
22490
22485
if (isFromInferenceBlockedSource(source)) {
22491
22486
return;
22492
22487
}
22493
22488
const inference = getInferenceInfoForType(target);
22494
22489
if (inference) {
22490
+ // If target is a type parameter, make an inference, unless the source type contains
22491
+ // a "non-inferrable" type. Types with this flag set are markers used to prevent inference.
22492
+ //
22493
+ // For example:
22494
+ // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions;
22495
+ // it's internal, so should not be exposed to the user by adding it as a candidate.
22496
+ // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType,
22497
+ // it's internal and should not be observable.
22498
+ // - silentNeverType is returned by getInferredType when instantiating a generic function for
22499
+ // inference (and a type variable has no mapping).
22500
+ //
22501
+ // This flag is infectious; if we produce Box<never> (where never is silentNeverType), Box<never> is
22502
+ // also non-inferrable.
22495
22503
if (getObjectFlags(source) & ObjectFlags.NonInferrableType) {
22496
22504
return;
22497
22505
}
0 commit comments