File: contextualTypingOfConditionalExpression2.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 (24 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
tests/cases/compiler/contextualTypingOfConditionalExpression2.ts(11,5): error TS2322: Type '((a: C) => number) | ((b: number) => void)' is not assignable to type '(a: A) => void'.
  Type '(b: number) => void' is not assignable to type '(a: A) => void'.
    Types of parameters 'b' and 'a' are incompatible.
      Type 'A' is not assignable to type 'number'.


==== tests/cases/compiler/contextualTypingOfConditionalExpression2.ts (1 errors) ====
    class A {
        foo: number;
    }
    class B extends A {
        bar: number;
    }
    class C extends A {
        baz: number;
    }
    
    var x2: (a: A) => void = true ? (a: C) => a.foo : (b: number) => { };
        ~~
!!! error TS2322: Type '((a: C) => number) | ((b: number) => void)' is not assignable to type '(a: A) => void'.
!!! error TS2322:   Type '(b: number) => void' is not assignable to type '(a: A) => void'.
!!! error TS2322:     Types of parameters 'b' and 'a' are incompatible.
!!! error TS2322:       Type 'A' is not assignable to type 'number'.