You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconstsafeVariance=<TypeextendsAnyConstructor>(type: Type,): SafeVarianceConstructor<Type>=>typeasSafeVarianceConstructor<Type>// this doesn't work because it needs to know how many generics the constructor takes.// intersecting it with `Type` in an attempt to fix that doesn't work because that just makes it return the original instance type and not the SafeVariance onetypeSafeVarianceConstructor<TypeextendsAnyConstructor>=Type&(new(...args: ConstructorParameters<Type>)=>SafeVariance<InstanceType<Type>>)
test('safeVariance',()=>{classA<T>extendssafeVariance(class<T>{// eslint-disable-next-line prefer-arrow/prefer-arrow-functions -- testing safeVariancefoo(_value: T){return1}},)<T>{}classB<T>extendssafeVariance(class<T>extendsA<T>{// eslint-disable-next-line prefer-arrow/prefer-arrow-functions -- testing safeVarianceoverridefoo(value: T){returnsuper.foo(value)}},)<T>{}consta=newB<number>()constb: B<unknown>=a// no error but there should be})
like #162 but for the whole class
The text was updated successfully, but these errors were encountered: