File: functionCallOnConstrainedTypeVariable.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 459,116 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (35 lines) | stat: -rw-r--r-- 1,469 bytes parent folder | download | duplicates (4)
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
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(11,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(15,7): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(18,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts(19,9): error TS2554: Expected 1 arguments, but got 4.


==== tests/cases/compiler/functionCallOnConstrainedTypeVariable.ts (4 errors) ====
    // Repro from #20196
    
    type A = {
      a: (x: number) => string
    };
    type B = {
      a: (x: boolean) => string
    };
    
    function call0(p: A | B) { 
      p.a("s"); // Error
          ~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
    }
    
    function callN<T extends A | B>(p: T) {
      p.a("s"); // Error
          ~~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
      
      var a: T["a"] = p.a;
      a(""); // Error
        ~~
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
      a("", "", "", ""); // Error
            ~~~~~~~~~~
!!! error TS2554: Expected 1 arguments, but got 4.
    }