2014-08-15 23:33:16 +02:00
|
|
|
=== tests/cases/compiler/genericInference2.ts ===
|
|
|
|
declare module ko {
|
2014-08-28 21:40:58 +02:00
|
|
|
>ko : typeof ko
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
export interface Observable<T> {
|
|
|
|
>Observable : Observable<T>
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
(): T;
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
(value: T): any;
|
|
|
|
>value : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
N: number;
|
|
|
|
>N : number
|
|
|
|
|
|
|
|
g: boolean;
|
|
|
|
>g : boolean
|
|
|
|
|
|
|
|
r: T;
|
|
|
|
>r : T
|
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
export function observable<T>(value: T): Observable<T>;
|
2014-08-28 21:52:44 +02:00
|
|
|
>observable : <T>(value: T) => Observable<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>T : T
|
|
|
|
>value : T
|
|
|
|
>T : T
|
2014-08-19 04:56:03 +02:00
|
|
|
>Observable : Observable<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>T : T
|
|
|
|
}
|
|
|
|
var o = {
|
2014-08-25 19:36:12 +02:00
|
|
|
>o : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
|
|
|
>{ name: ko.observable("Bob"), age: ko.observable(37) } : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
name: ko.observable("Bob"),
|
2014-08-25 19:36:12 +02:00
|
|
|
>name : ko.Observable<string>
|
|
|
|
>ko.observable("Bob") : ko.Observable<string>
|
2014-08-28 21:52:44 +02:00
|
|
|
>ko.observable : <T>(value: T) => ko.Observable<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>ko : typeof ko
|
2014-08-28 21:52:44 +02:00
|
|
|
>observable : <T>(value: T) => ko.Observable<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
age: ko.observable(37)
|
2014-08-25 19:36:12 +02:00
|
|
|
>age : ko.Observable<number>
|
|
|
|
>ko.observable(37) : ko.Observable<number>
|
2014-08-28 21:52:44 +02:00
|
|
|
>ko.observable : <T>(value: T) => ko.Observable<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
>ko : typeof ko
|
2014-08-28 21:52:44 +02:00
|
|
|
>observable : <T>(value: T) => ko.Observable<T>
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
var x_v = o.name().length; // should be 'number'
|
|
|
|
>x_v : number
|
|
|
|
>o.name().length : number
|
|
|
|
>o.name() : string
|
2014-08-25 19:36:12 +02:00
|
|
|
>o.name : ko.Observable<string>
|
|
|
|
>o : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
|
|
|
>name : ko.Observable<string>
|
2014-08-15 23:33:16 +02:00
|
|
|
>length : number
|
|
|
|
|
|
|
|
var age_v = o.age(); // should be 'number'
|
|
|
|
>age_v : number
|
|
|
|
>o.age() : number
|
2014-08-25 19:36:12 +02:00
|
|
|
>o.age : ko.Observable<number>
|
|
|
|
>o : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
|
|
|
>age : ko.Observable<number>
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var name_v = o.name("Robert"); // should be 'any'
|
|
|
|
>name_v : any
|
|
|
|
>o.name("Robert") : any
|
2014-08-25 19:36:12 +02:00
|
|
|
>o.name : ko.Observable<string>
|
|
|
|
>o : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
|
|
|
>name : ko.Observable<string>
|
2014-08-15 23:33:16 +02:00
|
|
|
|
|
|
|
var zz_v = o.name.N; // should be 'number'
|
|
|
|
>zz_v : number
|
|
|
|
>o.name.N : number
|
2014-08-25 19:36:12 +02:00
|
|
|
>o.name : ko.Observable<string>
|
|
|
|
>o : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
|
|
|
>name : ko.Observable<string>
|
2014-08-15 23:33:16 +02:00
|
|
|
>N : number
|
|
|
|
|
|
|
|
var yy_v = o.name.g; // should be 'boolean'
|
|
|
|
>yy_v : boolean
|
|
|
|
>o.name.g : boolean
|
2014-08-25 19:36:12 +02:00
|
|
|
>o.name : ko.Observable<string>
|
|
|
|
>o : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
|
|
|
>name : ko.Observable<string>
|
2014-08-15 23:33:16 +02:00
|
|
|
>g : boolean
|
|
|
|
|
|
|
|
var rr_v = o.name.r; // should be 'string'
|
|
|
|
>rr_v : string
|
|
|
|
>o.name.r : string
|
2014-08-25 19:36:12 +02:00
|
|
|
>o.name : ko.Observable<string>
|
|
|
|
>o : { name: ko.Observable<string>; age: ko.Observable<number>; }
|
|
|
|
>name : ko.Observable<string>
|
2014-08-15 23:33:16 +02:00
|
|
|
>r : string
|
|
|
|
|