TypeScript/tests/baselines/reference/objectTypeHidingMembersOfObjectAssignmentCompat2.errors.txt
2014-09-11 16:11:08 -07:00

47 lines
1.9 KiB
Plaintext

==== tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat2.ts (5 errors) ====
interface I {
toString(): number;
}
var i: I;
var o: Object;
o = i; // error
~
!!! error TS2322: Type 'I' is not assignable to type 'Object':
!!! error TS2322: Types of property 'toString' are incompatible:
!!! error TS2322: Type '() => number' is not assignable to type '() => string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
i = o; // error
~
!!! error TS2322: Type 'Object' is not assignable to type 'I':
!!! error TS2322: Types of property 'toString' are incompatible:
!!! error TS2322: Type '() => string' is not assignable to type '() => number':
!!! error TS2322: Type 'string' is not assignable to type 'number'.
class C {
toString(): number { return 1; }
}
var c: C;
o = c; // error
~
!!! error TS2322: Type 'C' is not assignable to type 'Object':
!!! error TS2322: Types of property 'toString' are incompatible:
!!! error TS2322: Type '() => number' is not assignable to type '() => string':
!!! error TS2322: Type 'number' is not assignable to type 'string'.
c = o; // error
~
!!! error TS2322: Type 'Object' is not assignable to type 'C':
!!! error TS2322: Types of property 'toString' are incompatible:
!!! error TS2322: Type '() => string' is not assignable to type '() => number':
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var a = {
toString: () => { }
}
o = a; // error
~
!!! error TS2322: Type '{ toString: () => void; }' is not assignable to type 'Object':
!!! error TS2322: Types of property 'toString' are incompatible:
!!! error TS2322: Type '() => void' is not assignable to type '() => string':
!!! error TS2322: Type 'void' is not assignable to type 'string'.
a = o; // ok