I have a function with one generic parameter, but with two function parameters. When I use "String Literal Type" the two function parameter can be have differt values:
function func2<T extends 'A' | 'B'>(x: T, y: T): void { }
func2('A', 'A'); // OK
func2('A', 'B'); // OK, why?
func2('A', 'C'); // ERR
But I need that x and y are the same, like the example with Classes:
class A { public a;}
class B { public b;}
class C { public c;}
function func1<T extends A | B>(x: T, y: T): void { }
func1(new A(), new A()); // OK
func1(new A(), new B()); // ERR
func1(new A(), new C()); // ERR
Is there any way that x and y have the same value with "String Literal Type"?
func2<T extends 'A' | 'B', U extends T>(x: T, y: U). That makes the second constraint depend on the first