File: assignmentCompatBug5.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (37 lines) | stat: -rw-r--r-- 2,248 bytes parent folder | download | duplicates (5)
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/assignmentCompatBug5.ts(2,8): error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
  Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
tests/cases/compiler/assignmentCompatBug5.ts(5,7): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatBug5.ts(5,12): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatBug5.ts(8,6): error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
  Types of parameters 's' and 'n' are incompatible.
    Type 'number' is not assignable to type 'string'.
tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
  Type 'void' is not assignable to type 'number'.


==== tests/cases/compiler/assignmentCompatBug5.ts (5 errors) ====
    function foo1(x: { a: number; }) { }
    foo1({ b: 5 });
           ~~~~
!!! error TS2345: Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
!!! error TS2345:   Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.
    
    function foo2(x: number[]) { }
    foo2(["s", "t"]);
          ~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
               ~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
    
    function foo3(x: (n: number) =>number) { };
    foo3((s:string) => { });
         ~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
!!! error TS2345:   Types of parameters 's' and 'n' are incompatible.
!!! error TS2345:     Type 'number' is not assignable to type 'string'.
    foo3((n) => { return; });
         ~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
!!! error TS2345:   Type 'void' is not assignable to type 'number'.