158 lines
2.3 KiB
Text
158 lines
2.3 KiB
Text
|
=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers3.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 implements S2 { foo: string; }
|
||
|
>S : S
|
||
|
>S2 : S2
|
||
|
>foo : string
|
||
|
|
||
|
class T implements T2 { foo: string; }
|
||
|
>T : T
|
||
|
>T2 : T2
|
||
|
>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: S2 = { foo: '' };
|
||
|
>a2 : S2
|
||
|
>S2 : S2
|
||
|
>{ foo: '' } : { foo: string; }
|
||
|
>foo : string
|
||
|
|
||
|
var b2: T2 = { foo: '' };
|
||
|
>b2 : T2
|
||
|
>T2 : T2
|
||
|
>{ 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 : S2
|
||
|
>s : S
|
||
|
>a2 : S2
|
||
|
|
||
|
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 : S2
|
||
|
>s2 : S2
|
||
|
>a2 : S2
|
||
|
|
||
|
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 : S2
|
||
|
>a : { foo: string; bar?: string; }
|
||
|
>a2 : S2
|
||
|
|
||
|
a2 = b2;
|
||
|
>a2 = b2 : T2
|
||
|
>a2 : S2
|
||
|
>b2 : T2
|
||
|
|
||
|
b2 = a2;
|
||
|
>b2 = a2 : S2
|
||
|
>b2 : T2
|
||
|
>a2 : S2
|
||
|
|
||
|
a2 = b;
|
||
|
>a2 = b : { foo: string; baz?: string; }
|
||
|
>a2 : S2
|
||
|
>b : { foo: string; baz?: string; }
|
||
|
|
||
|
a2 = t2;
|
||
|
>a2 = t2 : T2
|
||
|
>a2 : S2
|
||
|
>t2 : T2
|
||
|
|
||
|
a2 = t;
|
||
|
>a2 = t : T
|
||
|
>a2 : S2
|
||
|
>t : T
|
||
|
|