TypeScript/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt
2014-07-24 19:39:50 -07:00

30 lines
1.1 KiB
Plaintext

==== tests/cases/compiler/lastPropertyInLiteralWins.ts (3 errors) ====
interface Thing {
thunk: (str: string) => void;
}
function test(thing: Thing) {
thing.thunk("str");
}
test({ // Should error, as last one wins, and is wrong type
thunk: (str: string) => {},
thunk: (num: number) => {}
~~~~~
!!! Duplicate identifier 'thunk'.
});
test({ // Should be OK. Last 'thunk' is of correct type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
thunk: (num: number) => {},
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
thunk: (str: string) => {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~
!!! Duplicate identifier 'thunk'.
});
~
!!! Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
!!! Types of property 'thunk' are incompatible:
!!! Type '(num: number) => void' is not assignable to type '(str: string) => void':
!!! Types of parameters 'num' and 'str' are incompatible:
!!! Type 'number' is not assignable to type 'string'.