2014-07-13 01:04:16 +02:00
|
|
|
//// [genericCallWithObjectTypeArgsAndStringIndexer.ts]
|
|
|
|
// Type inference infers from indexers in target type, no errors expected
|
|
|
|
|
|
|
|
function foo<T>(x: T) {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: { [x: string]: Date };
|
|
|
|
var r = foo(a);
|
|
|
|
|
|
|
|
function other<T>(arg: T) {
|
|
|
|
var b: { [x: string]: T };
|
|
|
|
var r2 = foo(b); // T
|
|
|
|
}
|
|
|
|
|
|
|
|
function other2<T extends Date>(arg: T) {
|
|
|
|
var b: { [x: string]: T };
|
|
|
|
var r2 = foo(b);
|
|
|
|
var d: Date = r2['hm']; // ok
|
|
|
|
}
|
|
|
|
|
|
|
|
function other3<T extends Date, U extends Date>(arg: T) {
|
|
|
|
var b: { [x: string]: T };
|
|
|
|
var r2 = foo(b);
|
|
|
|
var d: Date = r2['hm']; // ok
|
|
|
|
// BUG 821629
|
|
|
|
//var u: U = r2['hm']; // ok
|
|
|
|
}
|
|
|
|
|
|
|
|
//function other3<T extends U, U extends Date>(arg: T) {
|
|
|
|
// var b: { [x: string]: T };
|
|
|
|
// var r2 = foo(b);
|
|
|
|
// var d: Date = r2['hm']; // ok
|
|
|
|
// // BUG 821629
|
|
|
|
// //var u: U = r2['hm']; // ok
|
|
|
|
//}
|
|
|
|
|
|
|
|
//// [genericCallWithObjectTypeArgsAndStringIndexer.js]
|
2014-08-14 15:21:30 +02:00
|
|
|
// Type inference infers from indexers in target type, no errors expected
|
2014-07-13 01:04:16 +02:00
|
|
|
function foo(x) {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
var a;
|
|
|
|
var r = foo(a);
|
|
|
|
function other(arg) {
|
|
|
|
var b;
|
2014-08-15 22:18:54 +02:00
|
|
|
var r2 = foo(b); // T
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
function other2(arg) {
|
|
|
|
var b;
|
|
|
|
var r2 = foo(b);
|
2014-08-15 22:18:54 +02:00
|
|
|
var d = r2['hm']; // ok
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
|
|
|
function other3(arg) {
|
|
|
|
var b;
|
|
|
|
var r2 = foo(b);
|
2014-08-15 22:18:54 +02:00
|
|
|
var d = r2['hm']; // ok
|
2014-08-22 02:17:02 +02:00
|
|
|
// BUG 821629
|
|
|
|
//var u: U = r2['hm']; // ok
|
2014-07-13 01:04:16 +02:00
|
|
|
}
|
2014-12-03 01:09:41 +01:00
|
|
|
//function other3<T extends U, U extends Date>(arg: T) {
|
|
|
|
// var b: { [x: string]: T };
|
|
|
|
// var r2 = foo(b);
|
|
|
|
// var d: Date = r2['hm']; // ok
|
|
|
|
// // BUG 821629
|
|
|
|
// //var u: U = r2['hm']; // ok
|
|
|
|
//}
|