File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -6700,8 +6700,21 @@ namespace ts {
6700
6700
return result;
6701
6701
}
6702
6702
6703
- // Presence of a contextual type mapper indicates inferential typing, except the identityMapper object is
6704
- // used as a special marker for other purposes.
6703
+ /**
6704
+ * Detect if the mapper implies an inference context. Specifically, there are 4 possible values
6705
+ * for a mapper. Let's go through each one of them:
6706
+ *
6707
+ * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing,
6708
+ * which could cause us to assign a parameter type
6709
+ * 2. identityMapper - means we want to avoid assigning a parameter type, whether or not we are in
6710
+ * inferential typing (context is undefined for the identityMapper)
6711
+ * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign
6712
+ * parameter types and fix type parameters (context is defined)
6713
+ * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be
6714
+ * passed as the contextual mapper when checking an expression (context is undefined for these)
6715
+ *
6716
+ * isInferentialContext is detecting if we are in case 3
6717
+ */
6705
6718
function isInferentialContext(mapper: TypeMapper) {
6706
6719
return mapper && mapper.context;
6707
6720
}
You can’t perform that action at this time.
0 commit comments