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

41 lines
1.9 KiB
Plaintext
Raw Normal View History

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'.
2014-10-01 02:15:18 +02:00
tests/cases/compiler/lastPropertyInLiteralWins.ts(13,5): error TS2300: Duplicate identifier 'thunk'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate identifier 'thunk'.
2014-10-01 02:15:18 +02:00
==== tests/cases/compiler/lastPropertyInLiteralWins.ts (5 errors) ====
2014-07-13 01:04:16 +02:00
interface Thing {
thunk: (str: string) => void;
}
function test(thing: Thing) {
thing.thunk("str");
}
test({ // Should error, as last one wins, and is wrong type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2014-07-13 01:04:16 +02:00
thunk: (str: string) => {},
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2014-07-13 01:04:16 +02:00
~~~~~
2014-10-01 02:15:18 +02:00
!!! error TS2300: Duplicate identifier 'thunk'.
thunk: (num: number) => {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2014-10-01 20:27:20 +02:00
~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
2014-07-13 01:04:16 +02:00
});
~
!!! 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'.
2014-07-13 01:04:16 +02:00
test({ // Should be OK. Last 'thunk' is of correct type
thunk: (num: number) => {},
2014-10-01 02:15:18 +02:00
~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
2014-07-13 01:04:16 +02:00
thunk: (str: string) => {}
2014-10-01 20:27:20 +02:00
~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
2014-07-13 01:04:16 +02:00
});