fd5b80805e
The new baselines all look correct to me, but obviously a number of the tests need to be updated to reflect union types and the new behavior of best common type. This commit does not cover that.
36 lines
2.1 KiB
Plaintext
36 lines
2.1 KiB
Plaintext
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(18,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
|
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,15): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
|
tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts(22,28): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
|
|
|
|
|
==== tests/cases/conformance/types/typeRelationships/bestCommonType/bestCommonTypeOfConditionalExpressions2.ts (3 errors) ====
|
|
// conditional expressions return the best common type of the branches plus contextual type (using the first candidate if multiple BCTs exist)
|
|
// these are errors
|
|
|
|
class Base { foo: string; }
|
|
class Derived extends Base { bar: string; }
|
|
class Derived2 extends Base { baz: string; }
|
|
var base: Base;
|
|
var derived: Derived;
|
|
var derived2: Derived2;
|
|
|
|
var r2 = true ? 1 : '';
|
|
var r9 = true ? derived : derived2;
|
|
|
|
function foo<T, U>(t: T, u: U) {
|
|
return true ? t : u;
|
|
}
|
|
|
|
function foo2<T extends U, U>(t: T, u: U) { // Error for referencing own type parameter
|
|
~~~~~~~~~~~
|
|
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
|
return true ? t : u; // Ok because BCT(T, U) = U
|
|
}
|
|
|
|
function foo3<T extends U, U extends V, V>(t: T, u: U) {
|
|
~~~~~~~~~~~
|
|
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
|
~~~~~~~~~~~
|
|
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
|
|
return true ? t : u;
|
|
} |