2017-01-16 01:26:17 +01:00
|
|
|
// @declaration: true
|
2017-01-12 01:11:16 +01:00
|
|
|
function generic<T>(t: T) {
|
|
|
|
var o: object = t; // expect error
|
|
|
|
}
|
2016-11-25 17:32:55 +01:00
|
|
|
var a = {};
|
|
|
|
var b = "42";
|
|
|
|
|
|
|
|
generic<object>({});
|
|
|
|
generic<object>(a);
|
|
|
|
generic<object>(123); // expect error
|
|
|
|
generic<object>(b); // expect error
|
|
|
|
|
2017-01-12 01:11:16 +01:00
|
|
|
function bound<T extends object>(t: T) {
|
|
|
|
var o: object = t; // ok
|
|
|
|
}
|
2016-11-25 17:32:55 +01:00
|
|
|
|
|
|
|
bound({});
|
|
|
|
bound(a);
|
|
|
|
bound(123); // expect error
|
|
|
|
bound(b); // expect error
|
2016-11-26 05:49:55 +01:00
|
|
|
|
|
|
|
function bound2<T extends object>() {}
|
|
|
|
|
|
|
|
bound2<{}>();
|
|
|
|
bound2<Object>();
|
|
|
|
bound2<number>(); // expect error
|
|
|
|
bound2<string>(); // expect error
|
2016-11-26 06:19:04 +01:00
|
|
|
|
2017-01-12 01:11:16 +01:00
|
|
|
function bound3<T extends {}>(t: T) {
|
|
|
|
var o: object = t; // ok
|
|
|
|
}
|
|
|
|
|
2016-11-26 06:19:04 +01:00
|
|
|
interface Proxy<T extends object> {}
|
|
|
|
|
|
|
|
var x: Proxy<number>; // error
|
|
|
|
var y: Proxy<null>; // ok
|
|
|
|
var z: Proxy<undefined> ; // ok
|
|
|
|
|
|
|
|
|
|
|
|
interface Blah {
|
2017-01-12 01:11:16 +01:00
|
|
|
foo: number;
|
2016-11-26 06:19:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
var u: Proxy<Blah>; // ok
|