Skip to content

Commit 7cf0d7c

Browse files
committed
add comments
1 parent a02f3b3 commit 7cf0d7c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19100,11 +19100,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1910019100
// Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
1910119101
// [2] Eg, if we have `Foo<T, U extends T>` and `Foo<Q, infer B>` where `Q` is mapped by `mapper` into `number` - `B` is constrained to `T`
1910219102
// which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
19103+
// [3] Eq, if we have `T extends `${infer R extends TOutput}` ? R : never` where `TOutput` is be mapped by `mapper` into `number`
19104+
// the R`s constraint has to be instantiated by `mapper` as that can influence inferences made for it
1910319105
// So we need to:
19106+
/// * clone the infer type parameters with local `extends` constraints
19107+
// * set the clones to both map the conditional's enclosing `mapper` and the original params
1910419108
// * combine `context.nonFixingMapper` with `mapper` so their constraints can be instantiated in the context of `mapper` (otherwise they'd only get inference context information)
1910519109
// * incorporate all of the component mappers into the combined mapper for the true and false members
19106-
// This means we have two mappers that need applying:
19110+
// This means we have three mappers that need applying:
1910719111
// * The original `mapper` used to create this conditional
19112+
// * The mapper that maps the old root type parameter to the clone (`freshMapper`)
1910819113
// * The mapper that maps the infer type parameter to its inference result (`context.mapper`)
1910919114
const freshParams = sameMap(root.inferTypeParameters, maybeCloneInferTypeParameter);
1911019115
const freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;

0 commit comments

Comments
 (0)