107 lines
1.5 KiB
Text
107 lines
1.5 KiB
Text
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithEmptyObject.ts ===
|
|
// valid uses of a basic object constraint, no errors expected
|
|
|
|
// Object constraint
|
|
function foo<T extends Object>(x: T) { }
|
|
>foo : <T extends Object>(x: T) => void
|
|
>T : T
|
|
>Object : Object
|
|
>x : T
|
|
>T : T
|
|
|
|
var r = foo({});
|
|
>r : void
|
|
>foo({}) : void
|
|
>foo : <T extends Object>(x: T) => void
|
|
>{} : {}
|
|
|
|
var a = {};
|
|
>a : {}
|
|
>{} : {}
|
|
|
|
var r = foo({});
|
|
>r : void
|
|
>foo({}) : void
|
|
>foo : <T extends Object>(x: T) => void
|
|
>{} : {}
|
|
|
|
class C<T extends Object> {
|
|
>C : C<T>
|
|
>T : T
|
|
>Object : Object
|
|
|
|
constructor(public x: T) { }
|
|
>x : T
|
|
>T : T
|
|
}
|
|
|
|
var r2 = new C({});
|
|
>r2 : C<{}>
|
|
>new C({}) : C<{}>
|
|
>C : typeof C
|
|
>{} : {}
|
|
|
|
interface I<T extends Object> {
|
|
>I : I<T>
|
|
>T : T
|
|
>Object : Object
|
|
|
|
x: T;
|
|
>x : T
|
|
>T : T
|
|
}
|
|
var i: I<{}>;
|
|
>i : I<{}>
|
|
>I : I<T>
|
|
|
|
// {} constraint
|
|
function foo2<T extends {}>(x: T) { }
|
|
>foo2 : <T extends {}>(x: T) => void
|
|
>T : T
|
|
>x : T
|
|
>T : T
|
|
|
|
var r = foo2({});
|
|
>r : void
|
|
>foo2({}) : void
|
|
>foo2 : <T extends {}>(x: T) => void
|
|
>{} : {}
|
|
|
|
var a = {};
|
|
>a : {}
|
|
>{} : {}
|
|
|
|
var r = foo2({});
|
|
>r : void
|
|
>foo2({}) : void
|
|
>foo2 : <T extends {}>(x: T) => void
|
|
>{} : {}
|
|
|
|
class C2<T extends {}> {
|
|
>C2 : C2<T>
|
|
>T : T
|
|
|
|
constructor(public x: T) { }
|
|
>x : T
|
|
>T : T
|
|
}
|
|
|
|
var r2 = new C2({});
|
|
>r2 : C<{}>
|
|
>new C2({}) : C2<{}>
|
|
>C2 : typeof C2
|
|
>{} : {}
|
|
|
|
interface I2<T extends {}> {
|
|
>I2 : I2<T>
|
|
>T : T
|
|
|
|
x: T;
|
|
>x : T
|
|
>T : T
|
|
}
|
|
var i2: I2<{}>;
|
|
>i2 : I2<{}>
|
|
>I2 : I2<T>
|
|
|
|
|