TypeScript/tests/baselines/reference/lastPropertyInLiteralWins.errors.txt

41 lines
1.9 KiB
Plaintext

tests/cases/compiler/lastPropertyInLiteralWins.ts(7,6): error TS2345: 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'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2300: Duplicate identifier 'thunk'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(13,5): error TS2300: Duplicate identifier 'thunk'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate identifier 'thunk'.
==== tests/cases/compiler/lastPropertyInLiteralWins.ts (5 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) => {},
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
thunk: (num: number) => {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
});
~
!!! error TS2345: Argument of type '{ thunk: (num: number) => void; }' is not assignable to parameter of type 'Thing'.
!!! error TS2345: Types of property 'thunk' are incompatible.
!!! error TS2345: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
test({ // Should be OK. Last 'thunk' is of correct type
thunk: (num: number) => {},
~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
thunk: (str: string) => {}
~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
});