Closed as not planned
Closed as not planned
Description
π Search Terms
variance class expression instantiation reference
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
class A<T = number> {
value!: T;
child!: typeof A.B<A<T>>; // errors
child2!: typeof A.B<A<T>>; // same as above but doesn't error
static B = class B<T extends A = A> {
parent!: T;
};
}
class A2<T = number> {
value!: T;
child!: typeof A2.B<A2<number>>;
child2!: typeof A2.B<A2<T>>; // same as A.child (and A.child2) but doesn't error
static B = class B<T extends A2 = A2> {
parent!: T;
};
}
π Actual behavior
child2
in both classes is free of errors
π Expected behavior
both child2
properties should contain errors (like child
in A
)
Additional information about the issue
This is related to the fact that child2
reenters getVariancesWorker
for the same symbol, so it returns with emptyArray
that was eagerly set as links.variances
on the first entry of this function. This, in turn, is a signal for structuredTypeRelatedToWorker
to return Ternary.Unknown
.
Since this is truly a circular situation, I think this is effectively a design limitation. I'm only reporting this for documentation purposes.