45 lines
No EOL
2.2 KiB
Text
45 lines
No EOL
2.2 KiB
Text
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(12,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':
|
|
Types of parameters 'num' and 'str' are incompatible:
|
|
Type 'number' is not assignable to type 'string'.
|
|
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'.
|
|
});
|
|
|
|
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'.
|
|
});
|
|
~
|
|
!!! 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':
|
|
!!! error TS2345: Types of parameters 'num' and 'str' are incompatible:
|
|
!!! error TS2345: Type 'number' is not assignable to type 'string'.
|
|
|