File: lastPropertyInLiteralWins.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (37 lines) | stat: -rw-r--r-- 1,958 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
tests/cases/compiler/lastPropertyInLiteralWins.ts(8,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
  Types of parameters 'num' and 'str' are incompatible.
    Type 'string' is not assignable to type 'number'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2300: Duplicate identifier 'thunk'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(9,5): error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
tests/cases/compiler/lastPropertyInLiteralWins.ts(14,5): error TS2300: Duplicate identifier 'thunk'.


==== tests/cases/compiler/lastPropertyInLiteralWins.ts (4 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 TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
!!! error TS2322:   Types of parameters 'num' and 'str' are incompatible.
!!! error TS2322:     Type 'string' is not assignable to type 'number'.
!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing'
        thunk: (num: number) => {}
        ~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
        ~~~~~
!!! error TS2322: Type '(num: number) => void' is not assignable to type '(str: string) => void'.
!!! related TS6500 tests/cases/compiler/lastPropertyInLiteralWins.ts:2:5: The expected type comes from property 'thunk' which is declared here on type 'Thing'
    });
    
    test({ // Should be OK.  Last 'thunk' is of correct type
        thunk: (num: number) => {},
        thunk: (str: string) => {}
        ~~~~~
!!! error TS2300: Duplicate identifier 'thunk'.
    });