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 {
|
2014-08-28 21:40:58 +02:00
|
|
|
>SimpleTypes : typeof SimpleTypes
|
2014-08-22 03:39:46 +02:00
|
|
|
|
|
|
|
class S { foo: string; }
|
|
|
|
>S : S
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
class T { foo: string; }
|
|
|
|
>T : T
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
var s: S;
|
|
|
|
>s : S
|
|
|
|
>S : S
|
|
|
|
|
|
|
|
var t: T;
|
|
|
|
>t : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
interface S2 { foo: string; }
|
|
|
|
>S2 : S2
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
interface T2 { foo: string; }
|
|
|
|
>T2 : T2
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
var s2: S2;
|
|
|
|
>s2 : S2
|
|
|
|
>S2 : S2
|
|
|
|
|
|
|
|
var t2: T2;
|
|
|
|
>t2 : T2
|
|
|
|
>T2 : T2
|
|
|
|
|
|
|
|
var a: { foo: string; }
|
|
|
|
>a : { foo: string; }
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
var b: { foo: string; }
|
|
|
|
>b : { foo: string; }
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
var a2 = { foo: '' };
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
>{ foo: '' } : { foo: string; }
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
var b2 = { foo: '' };
|
|
|
|
>b2 : { foo: string; }
|
|
|
|
>{ foo: '' } : { foo: string; }
|
|
|
|
>foo : string
|
|
|
|
|
|
|
|
s = t;
|
|
|
|
>s = t : T
|
|
|
|
>s : S
|
|
|
|
>t : T
|
|
|
|
|
|
|
|
t = s;
|
|
|
|
>t = s : S
|
|
|
|
>t : T
|
|
|
|
>s : S
|
|
|
|
|
|
|
|
s = s2;
|
|
|
|
>s = s2 : S2
|
|
|
|
>s : S
|
|
|
|
>s2 : S2
|
|
|
|
|
|
|
|
s = a2;
|
|
|
|
>s = a2 : { foo: string; }
|
|
|
|
>s : S
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
|
|
|
|
s2 = t2;
|
|
|
|
>s2 = t2 : T2
|
|
|
|
>s2 : S2
|
|
|
|
>t2 : T2
|
|
|
|
|
|
|
|
t2 = s2;
|
|
|
|
>t2 = s2 : S2
|
|
|
|
>t2 : T2
|
|
|
|
>s2 : S2
|
|
|
|
|
|
|
|
s2 = t;
|
|
|
|
>s2 = t : T
|
|
|
|
>s2 : S2
|
|
|
|
>t : T
|
|
|
|
|
|
|
|
s2 = b;
|
|
|
|
>s2 = b : { foo: string; }
|
|
|
|
>s2 : S2
|
|
|
|
>b : { foo: string; }
|
|
|
|
|
|
|
|
s2 = a2;
|
|
|
|
>s2 = a2 : { foo: string; }
|
|
|
|
>s2 : S2
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
|
|
|
|
a = b;
|
|
|
|
>a = b : { foo: string; }
|
|
|
|
>a : { foo: string; }
|
|
|
|
>b : { foo: string; }
|
|
|
|
|
|
|
|
b = a;
|
|
|
|
>b = a : { foo: string; }
|
|
|
|
>b : { foo: string; }
|
|
|
|
>a : { foo: string; }
|
|
|
|
|
|
|
|
a = s;
|
|
|
|
>a = s : S
|
|
|
|
>a : { foo: string; }
|
|
|
|
>s : S
|
|
|
|
|
|
|
|
a = s2;
|
|
|
|
>a = s2 : S2
|
|
|
|
>a : { foo: string; }
|
|
|
|
>s2 : S2
|
|
|
|
|
|
|
|
a = a2;
|
|
|
|
>a = a2 : { foo: string; }
|
|
|
|
>a : { foo: string; }
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
|
|
|
|
a2 = b2;
|
|
|
|
>a2 = b2 : { foo: string; }
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
>b2 : { foo: string; }
|
|
|
|
|
|
|
|
b2 = a2;
|
|
|
|
>b2 = a2 : { foo: string; }
|
|
|
|
>b2 : { foo: string; }
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
|
|
|
|
a2 = b;
|
|
|
|
>a2 = b : { foo: string; }
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
>b : { foo: string; }
|
|
|
|
|
|
|
|
a2 = t2;
|
|
|
|
>a2 = t2 : T2
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
>t2 : T2
|
|
|
|
|
|
|
|
a2 = t;
|
|
|
|
>a2 = t : T
|
|
|
|
>a2 : { foo: string; }
|
|
|
|
>t : T
|
|
|
|
}
|
|
|
|
|
|
|
|
module ObjectTypes {
|
2014-08-28 21:40:58 +02:00
|
|
|
>ObjectTypes : typeof ObjectTypes
|
2014-08-22 03:39:46 +02:00
|
|
|
|
|
|
|
class S { foo: S; }
|
|
|
|
>S : S
|
|
|
|
>foo : S
|
|
|
|
>S : S
|
|
|
|
|
|
|
|
class T { foo: T; }
|
|
|
|
>T : T
|
|
|
|
>foo : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
var s: S;
|
|
|
|
>s : S
|
|
|
|
>S : S
|
|
|
|
|
|
|
|
var t: T;
|
|
|
|
>t : T
|
|
|
|
>T : T
|
|
|
|
|
|
|
|
interface S2 { foo: S2; }
|
|
|
|
>S2 : S2
|
|
|
|
>foo : S2
|
|
|
|
>S2 : S2
|
|
|
|
|
|
|
|
interface T2 { foo: T2; }
|
|
|
|
>T2 : T2
|
|
|
|
>foo : T2
|
|
|
|
>T2 : T2
|
|
|
|
|
|
|
|
var s2: S2;
|
|
|
|
>s2 : S2
|
|
|
|
>S2 : S2
|
|
|
|
|
|
|
|
var t2: T2;
|
|
|
|
>t2 : T2
|
|
|
|
>T2 : T2
|
|
|
|
|
|
|
|
var a: { foo: typeof a; }
|
|
|
|
>a : { foo: any; }
|
|
|
|
>foo : { foo: any; }
|
|
|
|
>a : { foo: any; }
|
|
|
|
|
|
|
|
var b: { foo: typeof b; }
|
|
|
|
>b : { foo: any; }
|
|
|
|
>foo : { foo: any; }
|
|
|
|
>b : { foo: any; }
|
|
|
|
|
|
|
|
var a2 = { foo: a2 };
|
|
|
|
>a2 : any
|
|
|
|
>{ foo: a2 } : { foo: any; }
|
|
|
|
>foo : any
|
2014-08-25 19:36:12 +02:00
|
|
|
>a2 : any
|
2014-08-22 03:39:46 +02:00
|
|
|
|
|
|
|
var b2 = { foo: b2 };
|
|
|
|
>b2 : any
|
|
|
|
>{ foo: b2 } : { foo: any; }
|
|
|
|
>foo : any
|
2014-08-25 19:36:12 +02:00
|
|
|
>b2 : any
|
2014-08-22 03:39:46 +02:00
|
|
|
|
|
|
|
s = t;
|
|
|
|
>s = t : T
|
|
|
|
>s : S
|
|
|
|
>t : T
|
|
|
|
|
|
|
|
t = s;
|
|
|
|
>t = s : S
|
|
|
|
>t : T
|
|
|
|
>s : S
|
|
|
|
|
|
|
|
s = s2;
|
|
|
|
>s = s2 : S2
|
|
|
|
>s : S
|
|
|
|
>s2 : S2
|
|
|
|
|
|
|
|
s = a2;
|
|
|
|
>s = a2 : any
|
|
|
|
>s : S
|
|
|
|
>a2 : any
|
|
|
|
|
|
|
|
s2 = t2;
|
|
|
|
>s2 = t2 : T2
|
|
|
|
>s2 : S2
|
|
|
|
>t2 : T2
|
|
|
|
|
|
|
|
t2 = s2;
|
|
|
|
>t2 = s2 : S2
|
|
|
|
>t2 : T2
|
|
|
|
>s2 : S2
|
|
|
|
|
|
|
|
s2 = t;
|
|
|
|
>s2 = t : T
|
|
|
|
>s2 : S2
|
|
|
|
>t : T
|
|
|
|
|
|
|
|
s2 = b;
|
|
|
|
>s2 = b : { foo: any; }
|
|
|
|
>s2 : S2
|
|
|
|
>b : { foo: any; }
|
|
|
|
|
|
|
|
s2 = a2;
|
|
|
|
>s2 = a2 : any
|
|
|
|
>s2 : S2
|
|
|
|
>a2 : any
|
|
|
|
|
|
|
|
a = b;
|
|
|
|
>a = b : { foo: any; }
|
|
|
|
>a : { foo: any; }
|
|
|
|
>b : { foo: any; }
|
|
|
|
|
|
|
|
b = a;
|
|
|
|
>b = a : { foo: any; }
|
|
|
|
>b : { foo: any; }
|
|
|
|
>a : { foo: any; }
|
|
|
|
|
|
|
|
a = s;
|
|
|
|
>a = s : S
|
|
|
|
>a : { foo: any; }
|
|
|
|
>s : S
|
|
|
|
|
|
|
|
a = s2;
|
|
|
|
>a = s2 : S2
|
|
|
|
>a : { foo: any; }
|
|
|
|
>s2 : S2
|
|
|
|
|
|
|
|
a = a2;
|
|
|
|
>a = a2 : any
|
|
|
|
>a : { foo: any; }
|
|
|
|
>a2 : any
|
|
|
|
|
|
|
|
a2 = b2;
|
|
|
|
>a2 = b2 : any
|
|
|
|
>a2 : any
|
|
|
|
>b2 : any
|
|
|
|
|
|
|
|
b2 = a2;
|
|
|
|
>b2 = a2 : any
|
|
|
|
>b2 : any
|
|
|
|
>a2 : any
|
|
|
|
|
|
|
|
a2 = b;
|
|
|
|
>a2 = b : { foo: any; }
|
|
|
|
>a2 : any
|
|
|
|
>b : { foo: any; }
|
|
|
|
|
|
|
|
a2 = t2;
|
|
|
|
>a2 = t2 : T2
|
|
|
|
>a2 : any
|
|
|
|
>t2 : T2
|
|
|
|
|
|
|
|
a2 = t;
|
|
|
|
>a2 = t : T
|
|
|
|
>a2 : any
|
|
|
|
>t : T
|
|
|
|
|
|
|
|
}
|