Add and update difference type tests
This commit is contained in:
parent
f9ec6aa296
commit
d8b25a4371
|
@ -1,10 +1,12 @@
|
|||
type A = 'a';
|
||||
type B = 'b';
|
||||
type C = 'c';
|
||||
type AB = A | B;
|
||||
let nothing: A - 'a';
|
||||
let none: AB - 'a' | 'b';
|
||||
let over: 'a' - 'a' | 'b';
|
||||
let under: 'a' | 'b' - 'a';
|
||||
let partial: 'a' | 'b' - 'b' | 'd';
|
||||
let empty: AB - AB;
|
||||
let nope: string - string;
|
||||
let nope2: 'a' | 'b' - string;
|
||||
|
@ -14,5 +16,7 @@ let nope3: string - 'a' | 'b';
|
|||
// or keyof X? Check the mapped type code to decide what to do
|
||||
function f<T,U> (t: T, u: U) {
|
||||
let tsubu: T - U;
|
||||
let usubt: U - T;
|
||||
return tsubu;
|
||||
}
|
||||
|
||||
const x = f<'a' | 'b', 'b' | 'd'>('a', 'b');
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
type A = 'a';
|
||||
type B = 'b';
|
||||
type C = 'c';
|
||||
type AB = A | B;
|
||||
type AC = A | C;
|
||||
function f<T,U, V> (t: T, u: U, v: V) {
|
||||
let t_u: T - U;
|
||||
let t_v: T - V;
|
||||
let u_t: U - T;
|
||||
|
||||
t_u = t; // ok
|
||||
t_u = t_u; // ok
|
||||
t_u = t_v; // error
|
||||
|
||||
var t_a: T - A;
|
||||
var t_c: T - C;
|
||||
var t_ab: T - AB;
|
||||
|
||||
t_a = t_a; // ok
|
||||
t_ab = t_a; // ok
|
||||
t_a = t; // ok
|
||||
|
||||
t_a = t_c; // error
|
||||
t_a = t_ab; // error
|
||||
t = t_a; // error
|
||||
|
||||
var ab_u: AB - U;
|
||||
var ab_t: AB - T;
|
||||
var a_t: A - T;
|
||||
var ac_t: AC - T;
|
||||
|
||||
ab_t = ab_t; // ok
|
||||
ab_t = a_t; // error
|
||||
a_t = ab_t; // ok
|
||||
ab_u = ab_t; // error
|
||||
ab_t = ac_t // error
|
||||
}
|
Loading…
Reference in a new issue