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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
=== tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts ===
// Repro from #20196
type A = {
>A : Symbol(A, Decl(functionCallOnConstrainedTypeVariable.ts, 0, 0))
a: (x: number) => string
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10))
>x : Symbol(x, Decl(functionCallOnConstrainedTypeVariable.ts, 3, 6))
};
type B = {
>B : Symbol(B, Decl(functionCallOnConstrainedTypeVariable.ts, 4, 2))
a: (x: boolean) => string
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>x : Symbol(x, Decl(functionCallOnConstrainedTypeVariable.ts, 6, 6))
};
function call0(p: A | B) {
>call0 : Symbol(call0, Decl(functionCallOnConstrainedTypeVariable.ts, 7, 2))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 9, 15))
>A : Symbol(A, Decl(functionCallOnConstrainedTypeVariable.ts, 0, 0))
>B : Symbol(B, Decl(functionCallOnConstrainedTypeVariable.ts, 4, 2))
p.a("s"); // Error
>p.a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 9, 15))
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
}
function callN<T extends A | B>(p: T) {
>callN : Symbol(callN, Decl(functionCallOnConstrainedTypeVariable.ts, 11, 1))
>T : Symbol(T, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 15))
>A : Symbol(A, Decl(functionCallOnConstrainedTypeVariable.ts, 0, 0))
>B : Symbol(B, Decl(functionCallOnConstrainedTypeVariable.ts, 4, 2))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 32))
>T : Symbol(T, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 15))
p.a("s"); // Error
>p.a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 32))
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
var a: T["a"] = p.a;
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 16, 5))
>T : Symbol(T, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 15))
>p.a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
>p : Symbol(p, Decl(functionCallOnConstrainedTypeVariable.ts, 13, 32))
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 2, 10), Decl(functionCallOnConstrainedTypeVariable.ts, 5, 10))
a(""); // Error
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 16, 5))
a("", "", "", ""); // Error
>a : Symbol(a, Decl(functionCallOnConstrainedTypeVariable.ts, 16, 5))
}
|