TypeScript/tests/baselines/reference/assignmentCompatWithObjectMembers.types

313 lines
4.1 KiB
Plaintext
Raw Normal View History

2014-08-22 03:39:46 +02:00
=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers.ts ===
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// no errors expected
module SimpleTypes {
>SimpleTypes : typeof SimpleTypes
2014-08-22 03:39:46 +02:00
class S { foo: string; }
>S : S
>foo : string
2014-08-22 03:39:46 +02:00
class T { foo: string; }
>T : T
>foo : string
2014-08-22 03:39:46 +02:00
var s: S;
>s : S
>S : S
2014-08-22 03:39:46 +02:00
var t: T;
>t : T
>T : T
2014-08-22 03:39:46 +02:00
interface S2 { foo: string; }
>S2 : S2
>foo : string
2014-08-22 03:39:46 +02:00
interface T2 { foo: string; }
>T2 : T2
>foo : string
2014-08-22 03:39:46 +02:00
var s2: S2;
>s2 : S2
>S2 : S2
2014-08-22 03:39:46 +02:00
var t2: T2;
>t2 : T2
>T2 : T2
2014-08-22 03:39:46 +02:00
var a: { foo: string; }
>a : { foo: string; }
>foo : string
2014-08-22 03:39:46 +02:00
var b: { foo: string; }
>b : { foo: string; }
>foo : string
2014-08-22 03:39:46 +02:00
var a2 = { foo: '' };
>a2 : { foo: string; }
2014-08-22 03:39:46 +02:00
>{ foo: '' } : { foo: string; }
>foo : string
2015-04-13 21:36:11 +02:00
>'' : string
2014-08-22 03:39:46 +02:00
var b2 = { foo: '' };
>b2 : { foo: string; }
2014-08-22 03:39:46 +02:00
>{ foo: '' } : { foo: string; }
>foo : string
2015-04-13 21:36:11 +02:00
>'' : string
2014-08-22 03:39:46 +02:00
s = t;
>s = t : T
>s : S
>t : T
2014-08-22 03:39:46 +02:00
t = s;
>t = s : S
>t : T
>s : S
2014-08-22 03:39:46 +02:00
s = s2;
>s = s2 : S2
>s : S
>s2 : S2
2014-08-22 03:39:46 +02:00
s = a2;
>s = a2 : { foo: string; }
>s : S
>a2 : { foo: string; }
2014-08-22 03:39:46 +02:00
s2 = t2;
>s2 = t2 : T2
>s2 : S2
>t2 : T2
2014-08-22 03:39:46 +02:00
t2 = s2;
>t2 = s2 : S2
>t2 : T2
>s2 : S2
2014-08-22 03:39:46 +02:00
s2 = t;
>s2 = t : T
>s2 : S2
>t : T
2014-08-22 03:39:46 +02:00
s2 = b;
>s2 = b : { foo: string; }
>s2 : S2
>b : { foo: string; }
2014-08-22 03:39:46 +02:00
s2 = a2;
>s2 = a2 : { foo: string; }
>s2 : S2
>a2 : { foo: string; }
2014-08-22 03:39:46 +02:00
a = b;
>a = b : { foo: string; }
>a : { foo: string; }
>b : { foo: string; }
2014-08-22 03:39:46 +02:00
b = a;
>b = a : { foo: string; }
>b : { foo: string; }
>a : { foo: string; }
2014-08-22 03:39:46 +02:00
a = s;
>a = s : S
>a : { foo: string; }
>s : S
2014-08-22 03:39:46 +02:00
a = s2;
>a = s2 : S2
>a : { foo: string; }
>s2 : S2
2014-08-22 03:39:46 +02:00
a = a2;
>a = a2 : { foo: string; }
>a : { foo: string; }
>a2 : { foo: string; }
2014-08-22 03:39:46 +02:00
a2 = b2;
>a2 = b2 : { foo: string; }
>a2 : { foo: string; }
>b2 : { foo: string; }
2014-08-22 03:39:46 +02:00
b2 = a2;
>b2 = a2 : { foo: string; }
>b2 : { foo: string; }
>a2 : { foo: string; }
2014-08-22 03:39:46 +02:00
a2 = b;
>a2 = b : { foo: string; }
>a2 : { foo: string; }
>b : { foo: string; }
2014-08-22 03:39:46 +02:00
a2 = t2;
>a2 = t2 : T2
>a2 : { foo: string; }
>t2 : T2
2014-08-22 03:39:46 +02:00
a2 = t;
>a2 = t : T
>a2 : { foo: string; }
>t : T
2014-08-22 03:39:46 +02:00
}
module ObjectTypes {
>ObjectTypes : typeof ObjectTypes
2014-08-22 03:39:46 +02:00
class S { foo: S; }
>S : S
>foo : S
>S : S
2014-08-22 03:39:46 +02:00
class T { foo: T; }
>T : T
>foo : T
>T : T
2014-08-22 03:39:46 +02:00
var s: S;
>s : S
>S : S
2014-08-22 03:39:46 +02:00
var t: T;
>t : T
>T : T
2014-08-22 03:39:46 +02:00
interface S2 { foo: S2; }
>S2 : S2
>foo : S2
>S2 : S2
2014-08-22 03:39:46 +02:00
interface T2 { foo: T2; }
>T2 : T2
>foo : T2
>T2 : T2
2014-08-22 03:39:46 +02:00
var s2: S2;
>s2 : S2
>S2 : S2
2014-08-22 03:39:46 +02:00
var t2: T2;
>t2 : T2
>T2 : T2
2014-08-22 03:39:46 +02:00
var a: { foo: typeof a; }
>a : { foo: any; }
>foo : { foo: any; }
>a : { foo: any; }
2014-08-22 03:39:46 +02:00
var b: { foo: typeof b; }
>b : { foo: any; }
>foo : { foo: any; }
>b : { foo: any; }
2014-08-22 03:39:46 +02:00
var a2 = { foo: a2 };
>a2 : any
2014-08-22 03:39:46 +02:00
>{ foo: a2 } : { foo: any; }
>foo : any
>a2 : any
2014-08-22 03:39:46 +02:00
var b2 = { foo: b2 };
>b2 : any
2014-08-22 03:39:46 +02:00
>{ foo: b2 } : { foo: any; }
>foo : any
>b2 : any
2014-08-22 03:39:46 +02:00
s = t;
>s = t : T
>s : S
>t : T
2014-08-22 03:39:46 +02:00
t = s;
>t = s : S
>t : T
>s : S
2014-08-22 03:39:46 +02:00
s = s2;
>s = s2 : S2
>s : S
>s2 : S2
2014-08-22 03:39:46 +02:00
s = a2;
>s = a2 : any
>s : S
>a2 : any
2014-08-22 03:39:46 +02:00
s2 = t2;
>s2 = t2 : T2
>s2 : S2
>t2 : T2
2014-08-22 03:39:46 +02:00
t2 = s2;
>t2 = s2 : S2
>t2 : T2
>s2 : S2
2014-08-22 03:39:46 +02:00
s2 = t;
>s2 = t : T
>s2 : S2
>t : T
2014-08-22 03:39:46 +02:00
s2 = b;
>s2 = b : { foo: any; }
>s2 : S2
>b : { foo: any; }
2014-08-22 03:39:46 +02:00
s2 = a2;
>s2 = a2 : any
>s2 : S2
>a2 : any
2014-08-22 03:39:46 +02:00
a = b;
>a = b : { foo: any; }
>a : { foo: any; }
>b : { foo: any; }
2014-08-22 03:39:46 +02:00
b = a;
>b = a : { foo: any; }
>b : { foo: any; }
>a : { foo: any; }
2014-08-22 03:39:46 +02:00
a = s;
>a = s : S
>a : { foo: any; }
>s : S
2014-08-22 03:39:46 +02:00
a = s2;
>a = s2 : S2
>a : { foo: any; }
>s2 : S2
2014-08-22 03:39:46 +02:00
a = a2;
>a = a2 : any
>a : { foo: any; }
>a2 : any
2014-08-22 03:39:46 +02:00
a2 = b2;
>a2 = b2 : any
>a2 : any
>b2 : any
2014-08-22 03:39:46 +02:00
b2 = a2;
>b2 = a2 : any
>b2 : any
>a2 : any
2014-08-22 03:39:46 +02:00
a2 = b;
>a2 = b : { foo: any; }
>a2 : any
>b : { foo: any; }
2014-08-22 03:39:46 +02:00
a2 = t2;
>a2 = t2 : T2
>a2 : any
>t2 : T2
2014-08-22 03:39:46 +02:00
a2 = t;
>a2 = t : T
>a2 : any
>t : T
2014-08-22 03:39:46 +02:00
}