TypeScript/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.errors.txt
2014-09-12 13:35:07 -07:00

77 lines
3.9 KiB
Plaintext

tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts(13,22): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts(31,26): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts(39,19): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts(40,6): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts(42,14): error TS2339: Property 'foo' does not exist on type '{}'.
tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts(49,24): error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
==== tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints3.ts (6 errors) ====
// generic types should behave as if they have properties of their constraint type
class A {
foo(): string { return ''; }
}
class B extends A {
bar(): string {
return '';
}
}
class C<U extends A, T extends U> {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
f() {
var x: T;
// BUG 823818
var a = x['foo'](); // should be string
return a + x.foo();
}
g(x: U) {
// BUG 823818
var a = x['foo'](); // should be string
return a + x.foo();
}
}
var r1a = (new C<A, B>()).f();
var r1b = (new C<A, B>()).g(new B());
interface I<U extends A, T extends U> {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
foo: T;
}
var i: I<A, B>;
var r2 = i.foo.foo();
var r2b = i.foo['foo']();
var a: {
<U extends A, T extends U>(): T;
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
<U extends T, T extends A>(x: U): U;
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
}
var r3 = a().foo(); // error, no inferences for U so it doesn't satisfy constraint
~~~
!!! error TS2339: Property 'foo' does not exist on type '{}'.
var r3b = a()['foo']();
// 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
var r3d = a(new B())['foo'](); // valid call to an invalid function, U is inferred as B, which has a foo
var b = {
foo: <U extends A, T extends U>(x: T) => {
~~~~~~~~~~~
!!! error TS2313: Constraint of a type parameter cannot reference any type parameter from the same type parameter list.
// BUG 823818
var a = x['foo'](); // should be string
return a + x.foo();
}
}
var r4 = b.foo(new B()); // valid call to an invalid function