TypeScript/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.errors.txt
2014-07-12 17:30:19 -07:00

173 lines
6.2 KiB
Plaintext

==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersStringNumericNames.ts (29 errors) ====
// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M
// string named numeric properties work correctly, errors below unless otherwise noted
module JustStrings {
class S { '1': string; }
class T { '1.': string; }
var s: S;
var t: T;
interface S2 { '1': string; bar?: string }
interface T2 { '1.0': string; baz?: string }
var s2: S2;
var t2: T2;
var a: { '1.': string; bar?: string }
var b: { '1.0': string; baz?: string }
var a2 = { '1.0': '' };
var b2 = { '1': '' };
s = t;
~
!!! Type 'T' is not assignable to type 'S':
!!! Property ''1'' is missing in type 'T'.
t = s;
~
!!! Type 'S' is not assignable to type 'T':
!!! Property ''1.'' is missing in type 'S'.
s = s2; // ok
s = a2;
~
!!! Type '{ '1.0': string; }' is not assignable to type 'S':
!!! Property ''1'' is missing in type '{ '1.0': string; }'.
s2 = t2;
~~
!!! Type 'T2' is not assignable to type 'S2':
!!! Property ''1'' is missing in type 'T2'.
t2 = s2;
~~
!!! Type 'S2' is not assignable to type 'T2':
!!! Property ''1.0'' is missing in type 'S2'.
s2 = t;
~~
!!! Type 'T' is not assignable to type 'S2':
!!! Property ''1'' is missing in type 'T'.
s2 = b;
~~
!!! Type '{ '1.0': string; baz?: string; }' is not assignable to type 'S2':
!!! Property ''1'' is missing in type '{ '1.0': string; baz?: string; }'.
s2 = a2;
~~
!!! Type '{ '1.0': string; }' is not assignable to type 'S2':
!!! Property ''1'' is missing in type '{ '1.0': string; }'.
a = b;
~
!!! Type '{ '1.0': string; baz?: string; }' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type '{ '1.0': string; baz?: string; }'.
b = a;
~
!!! Type '{ '1.': string; bar?: string; }' is not assignable to type '{ '1.0': string; baz?: string; }':
!!! Property ''1.0'' is missing in type '{ '1.': string; bar?: string; }'.
a = s;
~
!!! Type 'S' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type 'S'.
a = s2;
~
!!! Type 'S2' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type 'S2'.
a = a2;
~
!!! Type '{ '1.0': string; }' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type '{ '1.0': string; }'.
a2 = b2;
~~
!!! Type '{ '1': string; }' is not assignable to type '{ '1.0': string; }':
!!! Property ''1.0'' is missing in type '{ '1': string; }'.
b2 = a2;
~~
!!! Type '{ '1.0': string; }' is not assignable to type '{ '1': string; }':
!!! Property ''1'' is missing in type '{ '1.0': string; }'.
a2 = b; // ok
a2 = t2; // ok
a2 = t;
~~
!!! Type 'T' is not assignable to type '{ '1.0': string; }':
!!! Property ''1.0'' is missing in type 'T'.
}
module NumbersAndStrings {
class S { '1': string; }
class T { 1: string; }
var s: S;
var t: T;
interface S2 { '1': string; bar?: string }
interface T2 { 1.0: string; baz?: string }
var s2: S2;
var t2: T2;
var a: { '1.': string; bar?: string }
var b: { 1.0: string; baz?: string }
var a2 = { '1.0': '' };
var b2 = { 1.: '' };
s = t; // ok
t = s; // ok
s = s2; // ok
s = a2; // error
~
!!! Type '{ '1.0': string; }' is not assignable to type 'S':
!!! Property ''1'' is missing in type '{ '1.0': string; }'.
s2 = t2; // ok
t2 = s2; // ok
s2 = t; // ok
s2 = b; // ok
s2 = a2; // error
~~
!!! Type '{ '1.0': string; }' is not assignable to type 'S2':
!!! Property ''1'' is missing in type '{ '1.0': string; }'.
a = b; // error
~
!!! Type '{ 1.0: string; baz?: string; }' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type '{ 1.0: string; baz?: string; }'.
b = a; // error
~
!!! Type '{ '1.': string; bar?: string; }' is not assignable to type '{ 1.0: string; baz?: string; }':
!!! Property '1.0' is missing in type '{ '1.': string; bar?: string; }'.
a = s; // error
~
!!! Type 'S' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type 'S'.
a = s2; // error
~
!!! Type 'S2' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type 'S2'.
a = a2; // error
~
!!! Type '{ '1.0': string; }' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type '{ '1.0': string; }'.
a = b2; // error
~
!!! Type '{ 1.: string; }' is not assignable to type '{ '1.': string; bar?: string; }':
!!! Property ''1.'' is missing in type '{ 1.: string; }'.
a2 = b2; // error
~~
!!! Type '{ 1.: string; }' is not assignable to type '{ '1.0': string; }':
!!! Property ''1.0'' is missing in type '{ 1.: string; }'.
b2 = a2; // error
~~
!!! Type '{ '1.0': string; }' is not assignable to type '{ 1.: string; }':
!!! Property '1.' is missing in type '{ '1.0': string; }'.
a2 = b; // error
~~
!!! Type '{ 1.0: string; baz?: string; }' is not assignable to type '{ '1.0': string; }':
!!! Property ''1.0'' is missing in type '{ 1.0: string; baz?: string; }'.
a2 = t2; // error
~~
!!! Type 'T2' is not assignable to type '{ '1.0': string; }':
!!! Property ''1.0'' is missing in type 'T2'.
a2 = t; // error
~~
!!! Type 'T' is not assignable to type '{ '1.0': string; }':
!!! Property ''1.0'' is missing in type 'T'.
}