Skip to content
Closed
97 changes: 75 additions & 22 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/baselines/reference/callsOnComplexSignatures.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== callsOnComplexSignatures.tsx ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== checkJsxChildrenCanBeTupleType.tsx ===
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/checkJsxChildrenProperty16.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== checkJsxChildrenProperty16.tsx ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== checkJsxUnionSFXContextualTypeInferredCorrectly.tsx ===
Expand Down
3 changes: 0 additions & 3 deletions tests/baselines/reference/circularBaseConstraint.types
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//// [tests/cases/compiler/circularBaseConstraint.ts] ////

=== Performance Stats ===
Instantiation count: 2,500

=== circularBaseConstraint.ts ===
// Repro from #54610

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//// [tests/cases/compiler/circularlySimplifyingConditionalTypesNoCrash.ts] ////

=== Performance Stats ===
Instantiation count: 2,500

=== circularlySimplifyingConditionalTypesNoCrash.ts ===
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
>Omit : Omit<T, K>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Strict subtype cache: 2,500
Assignability cache: 10,000
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000

=== conditionalTypeDiscriminatingLargeUnionRegularTypeFetchingSpeedReasonable.ts ===
type BigUnion =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Performance Stats ===
Type Count: 1,000
Instantiation count: 2,500 -> 5,000
Instantiation count: 2,500

=== conditionalTypeDoesntSpinForever.ts ===
// A *self-contained* demonstration of the problem follows...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 1,000
Type Count: 5,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== conditionalTypeVarianceBigArrayConstraintsPerformance.ts ===
Expand Down
3 changes: 0 additions & 3 deletions tests/baselines/reference/conditionalTypes1.types
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//// [tests/cases/conformance/types/conditional/conditionalTypes1.ts] ////

=== Performance Stats ===
Instantiation count: 1,000

=== conditionalTypes1.ts ===
type T00 = Exclude<"a" | "b" | "c" | "d", "a" | "c" | "f">; // "b" | "d"
>T00 : T00
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//// [tests/cases/compiler/contextualParameterAndSelfReferentialConstraint1.ts] ////

=== contextualParameterAndSelfReferentialConstraint1.ts ===
type NoExcessProperties<T, U> = T & {
>NoExcessProperties : Symbol(NoExcessProperties, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 0, 0))
>T : Symbol(T, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 0, 24))
>U : Symbol(U, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 0, 26))
>T : Symbol(T, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 0, 24))

readonly [K in Exclude<keyof U, keyof T>]: never;
>K : Symbol(K, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 1, 12))
>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --))
>U : Symbol(U, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 0, 26))
>T : Symbol(T, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 0, 24))

};

interface Effect<out A> {
>Effect : Symbol(Effect, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 2, 2))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 4, 17))

readonly EffectTypeId: {
>EffectTypeId : Symbol(Effect.EffectTypeId, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 4, 25))

readonly _A: (_: never) => A;
>_A : Symbol(_A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 5, 26))
>_ : Symbol(_, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 6, 18))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 4, 17))

};
}

declare function pipe<A, B>(a: A, ab: (a: A) => B): B;
>pipe : Symbol(pipe, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 8, 1))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 22))
>B : Symbol(B, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 24))
>a : Symbol(a, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 28))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 22))
>ab : Symbol(ab, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 33))
>a : Symbol(a, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 39))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 22))
>B : Symbol(B, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 24))
>B : Symbol(B, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 24))

interface RepeatOptions<A> {
>RepeatOptions : Symbol(RepeatOptions, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 54))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 12, 24))

until?: (_: A) => boolean;
>until : Symbol(RepeatOptions.until, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 12, 28))
>_ : Symbol(_, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 13, 11))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 12, 24))
}

declare const repeat: {
>repeat : Symbol(repeat, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 16, 13))

<O extends NoExcessProperties<RepeatOptions<A>, O>, A>(
>O : Symbol(O, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 3))
>NoExcessProperties : Symbol(NoExcessProperties, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 0, 0))
>RepeatOptions : Symbol(RepeatOptions, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 10, 54))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 53))
>O : Symbol(O, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 3))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 53))

options: O,
>options : Symbol(options, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 57))
>O : Symbol(O, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 3))

): (self: Effect<A>) => Effect<A>;
>self : Symbol(self, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 19, 6))
>Effect : Symbol(Effect, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 2, 2))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 53))
>Effect : Symbol(Effect, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 2, 2))
>A : Symbol(A, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 17, 53))

};

pipe(
>pipe : Symbol(pipe, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 8, 1))

{} as Effect<boolean>,
>Effect : Symbol(Effect, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 2, 2))

repeat({
>repeat : Symbol(repeat, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 16, 13))

until: (x) => {
>until : Symbol(until, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 24, 10))
>x : Symbol(x, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 25, 12))

return x; // boolean
>x : Symbol(x, Decl(contextualParameterAndSelfReferentialConstraint1.ts, 25, 12))

},
}),
);

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//// [tests/cases/compiler/contextualParameterAndSelfReferentialConstraint1.ts] ////

=== contextualParameterAndSelfReferentialConstraint1.ts ===
type NoExcessProperties<T, U> = T & {
>NoExcessProperties : NoExcessProperties<T, U>
> : ^^^^^^^^^^^^^^^^^^^^^^^^

readonly [K in Exclude<keyof U, keyof T>]: never;
};

interface Effect<out A> {
readonly EffectTypeId: {
>EffectTypeId : { readonly _A: (_: never) => A; }
> : ^^^^^^^^^^^^^^^ ^^^

readonly _A: (_: never) => A;
>_A : (_: never) => A
> : ^ ^^ ^^^^^
>_ : never
> : ^^^^^

};
}

declare function pipe<A, B>(a: A, ab: (a: A) => B): B;
>pipe : <A, B>(a: A, ab: (a: A) => B) => B
> : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^
>a : A
> : ^
>ab : (a: A) => B
> : ^ ^^ ^^^^^
>a : A
> : ^

interface RepeatOptions<A> {
until?: (_: A) => boolean;
>until : ((_: A) => boolean) | undefined
> : ^^ ^^ ^^^^^ ^^^^^^^^^^^^^
>_ : A
> : ^
}

declare const repeat: {
>repeat : <O extends NoExcessProperties<RepeatOptions<A>, O>, A>(options: O) => (self: Effect<A>) => Effect<A>
> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^

<O extends NoExcessProperties<RepeatOptions<A>, O>, A>(
options: O,
>options : O
> : ^

): (self: Effect<A>) => Effect<A>;
>self : Effect<A>
> : ^^^^^^^^^

};

pipe(
>pipe( {} as Effect<boolean>, repeat({ until: (x) => { return x; // boolean }, }),) : Effect<boolean>
> : ^^^^^^^^^^^^^^^
>pipe : <A, B>(a: A, ab: (a: A) => B) => B
> : ^ ^^ ^^ ^^ ^^ ^^ ^^^^^

{} as Effect<boolean>,
>{} as Effect<boolean> : Effect<boolean>
> : ^^^^^^^^^^^^^^^
>{} : {}
> : ^^

repeat({
>repeat({ until: (x) => { return x; // boolean }, }) : (self: Effect<boolean>) => Effect<boolean>
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>repeat : <O extends NoExcessProperties<RepeatOptions<A>, O>, A>(options: O) => (self: Effect<A>) => Effect<A>
> : ^ ^^^^^^^^^ ^^ ^^ ^^ ^^^^^
>{ until: (x) => { return x; // boolean }, } : { until: (x: boolean) => boolean; }
> : ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^

until: (x) => {
>until : (x: boolean) => boolean
> : ^ ^^^^^^^^^^^^^^^^^^^^^
>(x) => { return x; // boolean } : (x: boolean) => boolean
> : ^ ^^^^^^^^^^^^^^^^^^^^^
>x : boolean
> : ^^^^^^^

return x; // boolean
>x : boolean
> : ^^^^^^^

},
}),
);

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== contextuallyTypedJsxChildren.tsx ===
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/controlFlowOptionalChain3.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== controlFlowOptionalChain3.tsx ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Performance Stats ===
Type Count: 1,000
Instantiation count: 2,500 -> 5,000
Instantiation count: 2,500

=== declarationEmitHigherOrderRetainedGenerics.ts ===
export interface TypeLambda {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//// [tests/cases/compiler/declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.ts] ////

=== Performance Stats ===
Instantiation count: 500 -> 1,000

=== declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.ts ===
// Note that both of the following have an `any` in their return type from where we bottom out the type printout
// for having too many instances of the same symbol nesting.
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/deeplyNestedMappedTypes.types
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Performance Stats ===
Type Count: 1,000
Instantiation count: 10,000
Instantiation count: 5,000

=== deeplyNestedMappedTypes.ts ===
// Simplified repro from #55535
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Performance Stats ===
Type Count: 2,500
Instantiation count: 5,000
Instantiation count: 2,500

=== dependentDestructuredVariables.ts ===
type Action =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Performance Stats ===
Type Count: 2,500
Instantiation count: 10,000
Instantiation count: 5,000

=== divideAndConquerIntersections.ts ===
type QQ<T extends string[]> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 250,000
Instantiation count: 100,000
Symbol count: 100,000

=== errorInfoForRelatedIndexTypesNoConstraintElaboration.ts ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Performance Stats ===
Type Count: 1,000
Instantiation count: 2,500
Instantiation count: 1,000

=== index.tsx ===
interface MiddlewareArray<T> extends Array<T> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

=== Performance Stats ===
Type Count: 2,500
Instantiation count: 5,000
Instantiation count: 2,500

=== flatArrayNoExcessiveStackDepth.ts ===
// Repro from #43493
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/ignoredJsxAttributes.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== ignoredJsxAttributes.tsx ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== Performance Stats ===
Assignability cache: 2,500
Type Count: 10,000
Instantiation count: 100,000
Instantiation count: 50,000
Symbol count: 50,000

=== intraExpressionInferencesJsx.tsx ===
Expand Down
3 changes: 0 additions & 3 deletions tests/baselines/reference/isomorphicMappedTypeInference.types
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//// [tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts] ////

=== Performance Stats ===
Instantiation count: 2,500

=== isomorphicMappedTypeInference.ts ===
type Box<T> = {
>Box : Box<T>
Expand Down
Loading