98 lines
4.9 KiB
Text
98 lines
4.9 KiB
Text
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndStringIndexer.ts ===
|
|
// Type inference infers from indexers in target type, no errors expected
|
|
|
|
function foo<T>(x: T) {
|
|
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 0, 0))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 2, 13))
|
|
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 2, 16))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 2, 13))
|
|
|
|
return x;
|
|
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 2, 16))
|
|
}
|
|
|
|
var a: { [x: string]: Date };
|
|
>a : Symbol(a, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 6, 3))
|
|
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 6, 10))
|
|
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
|
|
var r = foo(a);
|
|
>r : Symbol(r, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 7, 3))
|
|
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 0, 0))
|
|
>a : Symbol(a, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 6, 3))
|
|
|
|
function other<T>(arg: T) {
|
|
>other : Symbol(other, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 7, 15))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 9, 15))
|
|
>arg : Symbol(arg, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 9, 18))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 9, 15))
|
|
|
|
var b: { [x: string]: T };
|
|
>b : Symbol(b, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 10, 7))
|
|
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 10, 14))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 9, 15))
|
|
|
|
var r2 = foo(b); // T
|
|
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 11, 7))
|
|
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 0, 0))
|
|
>b : Symbol(b, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 10, 7))
|
|
}
|
|
|
|
function other2<T extends Date>(arg: T) {
|
|
>other2 : Symbol(other2, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 12, 1))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 14, 16))
|
|
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>arg : Symbol(arg, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 14, 32))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 14, 16))
|
|
|
|
var b: { [x: string]: T };
|
|
>b : Symbol(b, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 15, 7))
|
|
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 15, 14))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 14, 16))
|
|
|
|
var r2 = foo(b);
|
|
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 16, 7))
|
|
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 0, 0))
|
|
>b : Symbol(b, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 15, 7))
|
|
|
|
var d: Date = r2['hm']; // ok
|
|
>d : Symbol(d, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 17, 7))
|
|
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 16, 7))
|
|
}
|
|
|
|
function other3<T extends Date, U extends Date>(arg: T) {
|
|
>other3 : Symbol(other3, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 18, 1))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 20, 16))
|
|
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>U : Symbol(U, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 20, 31))
|
|
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>arg : Symbol(arg, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 20, 48))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 20, 16))
|
|
|
|
var b: { [x: string]: T };
|
|
>b : Symbol(b, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 21, 7))
|
|
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 21, 14))
|
|
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 20, 16))
|
|
|
|
var r2 = foo(b);
|
|
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 22, 7))
|
|
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 0, 0))
|
|
>b : Symbol(b, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 21, 7))
|
|
|
|
var d: Date = r2['hm']; // ok
|
|
>d : Symbol(d, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 23, 7))
|
|
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgsAndStringIndexer.ts, 22, 7))
|
|
|
|
// 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
|
|
//}
|