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
typeFoo<T>={method(x: T): void;};typeFoo2<T>={method(x: T): void;};declareconsta1: Foo<(x: number)=>void>;declareconstb1: Foo<(x: number|string)=>void>;// Allowed?a1=b1;b1=a1;declareconsta1: Foo<(x: number)=>void>;declareconstb1: Foo2<(x: number|string)=>void>;// Not allowed - these don't rely on variance computations,// and during the structural comparison, we will apply// stricter variance checks between parameter types.// because the parameter types of 'method' are callbacks.a1=b1;b1=a1;
We compute variance and come up with one thing, but a structural comparison shows different results.
You can insantiate generics that would produce methods with callback parameters.
Structurally, these are incompatible because of stricter callback checks, but we consider them to be bivariant.
The fix was we started doing extra checks for weak types on the apparent type of an intersection when the source was an object.
Can we do something with our marker types to tell?
Is it possible that we could trigger the same covariant parameter checks when type parameter variance is computed as bivariant?
Maybe - but T can be used in more complicated types as well?
typeFoo<T>={method(x: T[SomeOtherType]): void;};
Actually, there are two trains of solving the problem that are going on in this meeting - erroring on the example in the surprisingly allowed case, and removing the error in the not allowed case.
Turns out main discussion point was actually the latter. The suggested solution would solve the former direction.
No definite ideas.
The text was updated successfully, but these errors were encountered:
Verbatim Module Syntax
#51479
importsNotUsedAsValues
andpreserveValueImports
. Does it replace them well?preserveValueImports
yesimportsNotUsedAsValues
?--verbatimImports
?--isolatedModules strict
?isolatedModules
comes up with rules for the most rudimentary bundler.--verbatimModuleSyntax
?--verbatimModuleSyntax
Variance-Based Comparisons Differ from Structural Comparisons
#51620
Maybe - but
T
can be used in more complicated types as well?The text was updated successfully, but these errors were encountered: