File: objectLiteralFunctionArgContextualTyping2.errors.txt

package info (click to toggle)
node-typescript 5.1.6%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 492,516 kB
  • sloc: javascript: 2,078,951; makefile: 6; sh: 1
file content (47 lines) | stat: -rw-r--r-- 3,382 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(8,6): error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'.
  Object literal may only specify known properties, and 'hello' does not exist in type 'I2'.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(9,4): error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'.
  Property 'doStuff' is missing in type '{ value: string; }' but required in type 'I2'.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(10,17): error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'.
  Object literal may only specify known properties, and 'what' does not exist in type 'I2'.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(11,6): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
  Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(12,6): error TS2322: Type '(s: string) => string' is not assignable to type '() => string'.
  Target signature provides too few arguments. Expected 1 or more, but got 0.
tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts(13,17): error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
  Target signature provides too few arguments. Expected 1 or more, but got 0.


==== tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts (6 errors) ====
    interface I2 {
        value: string;
        doStuff: (t: string) => string;
    }
    
    function f2(args: I2) { }
    
    f2({ hello: 1 }) 
         ~~~~~
!!! error TS2345: Argument of type '{ hello: number; }' is not assignable to parameter of type 'I2'.
!!! error TS2345:   Object literal may only specify known properties, and 'hello' does not exist in type 'I2'.
    f2({ value: '' })
       ~~~~~~~~~~~~~
!!! error TS2345: Argument of type '{ value: string; }' is not assignable to parameter of type 'I2'.
!!! error TS2345:   Property 'doStuff' is missing in type '{ value: string; }' but required in type 'I2'.
!!! related TS2728 tests/cases/compiler/objectLiteralFunctionArgContextualTyping2.ts:3:5: 'doStuff' is declared here.
    f2({ value: '', what: 1 }) 
                    ~~~~
!!! error TS2345: Argument of type '{ value: string; what: number; }' is not assignable to parameter of type 'I2'.
!!! error TS2345:   Object literal may only specify known properties, and 'what' does not exist in type 'I2'.
    f2({ toString: (s) => s }) 
         ~~~~~~~~
!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
!!! error TS2322:   Target signature provides too few arguments. Expected 1 or more, but got 0.
    f2({ toString: (s: string) => s }) 
         ~~~~~~~~
!!! error TS2322: Type '(s: string) => string' is not assignable to type '() => string'.
!!! error TS2322:   Target signature provides too few arguments. Expected 1 or more, but got 0.
    f2({ value: '', toString: (s) => s.uhhh }) 
                    ~~~~~~~~
!!! error TS2322: Type '(s: any) => any' is not assignable to type '() => string'.
!!! error TS2322:   Target signature provides too few arguments. Expected 1 or more, but got 0.