37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
==== tests/cases/conformance/types/members/objectTypeHidingMembersOfObjectAssignmentCompat.ts (3 errors) ====
|
|
interface I {
|
|
toString(): void;
|
|
}
|
|
|
|
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 '() => void' is not assignable to type '() => string':
|
|
!!! error TS2322: Type 'void' is not assignable to type 'string'.
|
|
i = o; // ok
|
|
|
|
class C {
|
|
toString(): void { }
|
|
}
|
|
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 '() => void' is not assignable to type '() => string':
|
|
!!! error TS2322: Type 'void' is not assignable to type 'string'.
|
|
c = o; // ok
|
|
|
|
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 |