2014-07-13 01:04:16 +02:00
|
|
|
//// [constraintsThatReferenceOtherContstraints1.ts]
|
|
|
|
interface Object { }
|
|
|
|
|
|
|
|
class Foo<T, U extends T> { }
|
|
|
|
class Bar<T extends Object, U extends T> {
|
|
|
|
data: Foo<Object, Object>; // Error 1 Type 'Object' does not satisfy the constraint 'T' for type parameter 'U extends T'.
|
|
|
|
}
|
|
|
|
|
|
|
|
var x: Foo< { a: string }, { a: string; b: number }>; // Error 2 Type '{ a: string; b: number; }' does not satisfy the constraint 'T' for type
|
|
|
|
|
|
|
|
|
|
|
|
//// [constraintsThatReferenceOtherContstraints1.js]
|
|
|
|
var Foo = (function () {
|
|
|
|
function Foo() {
|
|
|
|
}
|
|
|
|
return Foo;
|
|
|
|
})();
|
|
|
|
var Bar = (function () {
|
|
|
|
function Bar() {
|
|
|
|
}
|
|
|
|
return Bar;
|
|
|
|
})();
|
2014-08-15 22:18:54 +02:00
|
|
|
var x; // Error 2 Type '{ a: string; b: number; }' does not satisfy the constraint 'T' for type
|