1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(11,7): error TS2345: Argument of type '"s"' is not assignable to parameter of type 'never'.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(15,7): error TS2345: Argument of type '"s"' is not assignable to parameter of type 'never'.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(18,5): error TS2345: Argument of type '""' is not assignable to parameter of type 'never'.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(19,3): error TS2554: Expected 1 arguments, but got 4.
==== tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts (4 errors) ====
// Repro from #20196
type A = {
a: (x: number) => string
};
type B = {
a: (x: boolean) => string
};
function call0(p: A | B) {
p.a("s"); // Error
~~~
!!! error TS2345: Argument of type '"s"' is not assignable to parameter of type 'never'.
}
function callN<T extends A | B>(p: T) {
p.a("s"); // Error
~~~
!!! error TS2345: Argument of type '"s"' is not assignable to parameter of type 'never'.
var a: T["a"] = p.a;
a(""); // Error
~~
!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'never'.
a("", "", "", ""); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 4.
}
|