2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts (24 errors) ====
|
|
|
|
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
|
|
|
|
|
|
|
|
module TargetIsPublic {
|
|
|
|
// targets
|
|
|
|
class Base {
|
|
|
|
public foo: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I {
|
|
|
|
foo: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: { foo: string; }
|
|
|
|
var b: Base;
|
|
|
|
var i: I;
|
|
|
|
|
|
|
|
// sources
|
|
|
|
class D {
|
|
|
|
public foo: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class E {
|
|
|
|
private foo: string;
|
|
|
|
}
|
|
|
|
var d: D;
|
|
|
|
var e: E;
|
|
|
|
|
|
|
|
a = b;
|
|
|
|
a = i;
|
|
|
|
a = d;
|
|
|
|
a = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type '{ foo: string; }':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
b = a;
|
|
|
|
b = i;
|
|
|
|
b = d;
|
|
|
|
b = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type 'Base':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'Base'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
i = a;
|
|
|
|
i = b;
|
|
|
|
i = d;
|
|
|
|
i = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type 'I':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'I'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
d = a;
|
|
|
|
d = b;
|
|
|
|
d = i;
|
|
|
|
d = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type 'D':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
e = a; // errror
|
|
|
|
~
|
|
|
|
!!! Type '{ foo: string; }' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = b; // errror
|
|
|
|
~
|
|
|
|
!!! Type 'Base' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'Base'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = i; // errror
|
|
|
|
~
|
|
|
|
!!! Type 'I' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'I'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = d; // errror
|
|
|
|
~
|
|
|
|
!!! Type 'D' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module TargetIsPublic {
|
|
|
|
// targets
|
|
|
|
class Base {
|
|
|
|
private foo: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I extends Base {
|
|
|
|
}
|
|
|
|
|
|
|
|
var a: { foo: string; }
|
|
|
|
var b: Base;
|
|
|
|
var i: I;
|
|
|
|
|
|
|
|
// sources
|
|
|
|
class D {
|
|
|
|
public foo: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
class E {
|
|
|
|
private foo: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
var d: D;
|
|
|
|
var e: E;
|
|
|
|
|
|
|
|
a = b; // error
|
|
|
|
~
|
|
|
|
!!! Type 'Base' is not assignable to type '{ foo: string; }':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
a = i; // error
|
|
|
|
~
|
|
|
|
!!! Type 'I' is not assignable to type '{ foo: string; }':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'I' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
a = d;
|
|
|
|
a = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type '{ foo: string; }':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
b = a; // error
|
|
|
|
~
|
|
|
|
!!! Type '{ foo: string; }' is not assignable to type 'Base':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
b = i;
|
|
|
|
b = d; // error
|
|
|
|
~
|
|
|
|
!!! Type 'D' is not assignable to type 'Base':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'Base' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
b = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type 'Base':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Types have separate declarations of a private property 'foo'.
|
2014-07-13 01:04:16 +02:00
|
|
|
b = b;
|
|
|
|
|
|
|
|
i = a; // error
|
|
|
|
~
|
|
|
|
!!! Type '{ foo: string; }' is not assignable to type 'I':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'I' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
i = b;
|
|
|
|
i = d; // error
|
|
|
|
~
|
|
|
|
!!! Type 'D' is not assignable to type 'I':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'I' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
i = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type 'I':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Types have separate declarations of a private property 'foo'.
|
2014-07-13 01:04:16 +02:00
|
|
|
i = i;
|
|
|
|
|
|
|
|
d = a;
|
|
|
|
d = b; // error
|
|
|
|
~
|
|
|
|
!!! Type 'Base' is not assignable to type 'D':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'Base' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
d = i; // error
|
|
|
|
~
|
|
|
|
!!! Type 'I' is not assignable to type 'D':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'I' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
d = e; // error
|
|
|
|
~
|
|
|
|
!!! Type 'E' is not assignable to type 'D':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
e = a; // errror
|
|
|
|
~
|
|
|
|
!!! Type '{ foo: string; }' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type '{ foo: string; }'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = b; // errror
|
|
|
|
~
|
|
|
|
!!! Type 'Base' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Types have separate declarations of a private property 'foo'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = i; // errror
|
|
|
|
~
|
|
|
|
!!! Type 'I' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Types have separate declarations of a private property 'foo'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = d; // errror
|
|
|
|
~
|
|
|
|
!!! Type 'D' is not assignable to type 'E':
|
2014-09-17 19:36:32 +02:00
|
|
|
!!! Property 'foo' is private in type 'E' but not in type 'D'.
|
2014-07-13 01:04:16 +02:00
|
|
|
e = e;
|
|
|
|
|
|
|
|
}
|