Skip to content

Commit 2974d9a

Browse files
committed
Rewrite and move comment to the correct place
1 parent 6dad0a4 commit 2974d9a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/compiler/checker.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22480,18 +22480,26 @@ namespace ts {
2248022480
target = getActualTypeVariable(target);
2248122481
}
2248222482
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.
2249022485
if (isFromInferenceBlockedSource(source)) {
2249122486
return;
2249222487
}
2249322488
const inference = getInferenceInfoForType(target);
2249422489
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.
2249522503
if (getObjectFlags(source) & ObjectFlags.NonInferrableType) {
2249622504
return;
2249722505
}

0 commit comments

Comments
 (0)