Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Oct 26, 2024
1 parent a02f3b3 commit 7cf0d7c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19100,11 +19100,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// Conversely, if we have `Foo<infer A, infer B>`, `B` is still constrained to `T` and `T` is instantiated as `A`
// [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`
// which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
// [3] Eq, if we have `T extends `${infer R extends TOutput}` ? R : never` where `TOutput` is be mapped by `mapper` into `number`
// the R`s constraint has to be instantiated by `mapper` as that can influence inferences made for it
// So we need to:
/// * clone the infer type parameters with local `extends` constraints
// * set the clones to both map the conditional's enclosing `mapper` and the original params
// * combine `context.nonFixingMapper` with `mapper` so their constraints can be instantiated in the context of `mapper` (otherwise they'd only get inference context information)
// * incorporate all of the component mappers into the combined mapper for the true and false members
// This means we have two mappers that need applying:
// This means we have three mappers that need applying:
// * The original `mapper` used to create this conditional
// * The mapper that maps the old root type parameter to the clone (`freshMapper`)
// * The mapper that maps the infer type parameter to its inference result (`context.mapper`)
const freshParams = sameMap(root.inferTypeParameters, maybeCloneInferTypeParameter);
const freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
Expand Down

0 comments on commit 7cf0d7c

Please sign in to comment.