155 lines
2.5 KiB
Text
155 lines
2.5 KiB
Text
=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers2.ts ===
|
|
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
|
|
// additional optional properties do not cause errors
|
|
|
|
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; bar?: string }
|
|
>S2 : S2
|
|
>foo : string
|
|
>bar : string
|
|
|
|
interface T2 { foo: string; baz?: string }
|
|
>T2 : T2
|
|
>foo : string
|
|
>baz : string
|
|
|
|
var s2: S2;
|
|
>s2 : S2
|
|
>S2 : S2
|
|
|
|
var t2: T2;
|
|
>t2 : T2
|
|
>T2 : T2
|
|
|
|
var a: { foo: string; bar?: string }
|
|
>a : { foo: string; bar?: string; }
|
|
>foo : string
|
|
>bar : string
|
|
|
|
var b: { foo: string; baz?: string }
|
|
>b : { foo: string; baz?: string; }
|
|
>foo : string
|
|
>baz : string
|
|
|
|
var a2 = { foo: '' };
|
|
>a2 : { foo: string; }
|
|
>{ foo: '' } : { foo: string; }
|
|
>foo : string
|
|
>'' : string
|
|
|
|
var b2 = { foo: '' };
|
|
>b2 : { foo: string; }
|
|
>{ foo: '' } : { foo: string; }
|
|
>foo : string
|
|
>'' : 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; baz?: string; }
|
|
>s2 : S2
|
|
>b : { foo: string; baz?: string; }
|
|
|
|
s2 = a2;
|
|
>s2 = a2 : { foo: string; }
|
|
>s2 : S2
|
|
>a2 : { foo: string; }
|
|
|
|
a = b;
|
|
>a = b : { foo: string; baz?: string; }
|
|
>a : { foo: string; bar?: string; }
|
|
>b : { foo: string; baz?: string; }
|
|
|
|
b = a;
|
|
>b = a : { foo: string; bar?: string; }
|
|
>b : { foo: string; baz?: string; }
|
|
>a : { foo: string; bar?: string; }
|
|
|
|
a = s;
|
|
>a = s : S
|
|
>a : { foo: string; bar?: string; }
|
|
>s : S
|
|
|
|
a = s2;
|
|
>a = s2 : S2
|
|
>a : { foo: string; bar?: string; }
|
|
>s2 : S2
|
|
|
|
a = a2;
|
|
>a = a2 : { foo: string; }
|
|
>a : { foo: string; bar?: 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; baz?: string; }
|
|
>a2 : { foo: string; }
|
|
>b : { foo: string; baz?: string; }
|
|
|
|
a2 = t2;
|
|
>a2 = t2 : T2
|
|
>a2 : { foo: string; }
|
|
>t2 : T2
|
|
|
|
a2 = t;
|
|
>a2 = t : T
|
|
>a2 : { foo: string; }
|
|
>t : T
|
|
|