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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
=== tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts ===
// generic types should behave as if they have properties of their constraint type
class A {
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
foo(): string { return ''; }
>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
}
class B extends A {
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
bar(): string {
>bar : Symbol(B.bar, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 6, 19))
return '';
}
}
class C<U extends A, T extends U> {
>C : Symbol(C, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 10, 1))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 8))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 20))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 8))
f() {
>f : Symbol(C.f, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 35))
var x: T;
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 14, 11))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 20))
// BUG 823818
var a = x['foo'](); // should be string
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 16, 11))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 14, 11))
>'foo' : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
return a + x.foo();
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 16, 11))
>x.foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 14, 11))
>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
}
g(x: U) {
>g : Symbol(C.g, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 18, 5))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 20, 6))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 8))
// BUG 823818
var a = x['foo'](); // should be string
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 22, 11))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 20, 6))
>'foo' : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
return a + x.foo();
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 22, 11))
>x.foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 20, 6))
>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
}
}
var r1a = (new C<A, B>()).f();
>r1a : Symbol(r1a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 27, 3))
>(new C<A, B>()).f : Symbol(C.f, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 35))
>C : Symbol(C, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 10, 1))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
>f : Symbol(C.f, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 12, 35))
var r1b = (new C<A, B>()).g(new B());
>r1b : Symbol(r1b, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 28, 3))
>(new C<A, B>()).g : Symbol(C.g, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 18, 5))
>C : Symbol(C, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 10, 1))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
>g : Symbol(C.g, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 18, 5))
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
interface I<U extends A, T extends U> {
>I : Symbol(I, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 28, 37))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 12))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 24))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 12))
foo: T;
>foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 39))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 24))
}
var i: I<A, B>;
>i : Symbol(i, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 33, 3))
>I : Symbol(I, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 28, 37))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
var r2 = i.foo.foo();
>r2 : Symbol(r2, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 34, 3))
>i.foo.foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
>i.foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 39))
>i : Symbol(i, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 33, 3))
>foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 39))
>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
var r2b = i.foo['foo']();
>r2b : Symbol(r2b, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 35, 3))
>i.foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 39))
>i : Symbol(i, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 33, 3))
>foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 30, 39))
>'foo' : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
var a: {
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 37, 3))
<U extends A, T extends U>(): T;
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 38, 5))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 38, 17))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 38, 5))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 38, 17))
<U extends T, T extends A>(x: U): U;
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 39, 5))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 39, 17))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 39, 17))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 39, 31))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 39, 5))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 39, 5))
}
var r3 = a().foo(); // error, no inferences for U so it doesn't satisfy constraint
>r3 : Symbol(r3, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 41, 3))
>a().foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 37, 3))
>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
var r3b = a()['foo']();
>r3b : Symbol(r3b, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 42, 3))
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 37, 3))
>'foo' : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
// parameter supplied for type argument inference for U
var r3c = a(new B()).foo(); // valid call to an invalid function, U is inferred as B, which has a foo
>r3c : Symbol(r3c, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 44, 3))
>a(new B()).foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 37, 3))
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
var r3d = a(new B())['foo'](); // valid call to an invalid function, U is inferred as B, which has a foo
>r3d : Symbol(r3d, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 45, 3))
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 37, 3))
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
>'foo' : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
var b = {
>b : Symbol(b, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 47, 3))
foo: <U extends A, T extends U>(x: T) => {
>foo : Symbol(foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 47, 9))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 48, 10))
>A : Symbol(A, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 0, 0))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 48, 22))
>U : Symbol(U, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 48, 10))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 48, 36))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 48, 22))
// BUG 823818
var a = x['foo'](); // should be string
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 50, 11))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 48, 36))
>'foo' : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
return a + x.foo();
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 50, 11))
>x.foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 48, 36))
>foo : Symbol(A.foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 2, 9))
}
}
var r4 = b.foo(new B()); // valid call to an invalid function
>r4 : Symbol(r4, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 55, 3))
>b.foo : Symbol(foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 47, 9))
>b : Symbol(b, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 47, 3))
>foo : Symbol(foo, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 47, 9))
>B : Symbol(B, Decl(propertyAccessOnTypeParameterWithConstraints3.ts, 4, 1))
|