File: tsxStatelessFunctionComponentsWithTypeArguments2.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 (56 lines) | stat: -rw-r--r-- 3,275 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
48
49
50
51
52
53
54
55
56
tests/cases/conformance/jsx/file.tsx(8,43): error TS2322: Type '10' is not assignable to type 'string'.
tests/cases/conformance/jsx/file.tsx(13,15): error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { prop: {}; "ignore-prop": string; }'.
  Type 'T' is not assignable to type '{ prop: {}; "ignore-prop": string; }'.
tests/cases/conformance/jsx/file.tsx(20,19): error TS2322: Type '(a: number, b: string) => void' is not assignable to type '(arg: number) => void'.
tests/cases/conformance/jsx/file.tsx(31,52): error TS2322: Type '(val: string) => void' is not assignable to type '(selectedVal: number) => void'.
  Types of parameters 'val' and 'selectedVal' are incompatible.
    Type 'number' is not assignable to type 'string'.


==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
    import React = require('react')
    
    declare function ComponentSpecific1<U>(l: {prop: U, "ignore-prop": string}): JSX.Element;
    declare function ComponentSpecific2<U>(l: {prop: U}): JSX.Element;
    
    // Error
    function Bar<T extends {prop: number}>(arg: T) {
        let a1 = <ComponentSpecific1 {...arg} ignore-prop={10} />;
                                              ~~~~~~~~~~~
!!! error TS2322: Type '10' is not assignable to type 'string'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:3:53: The expected type comes from property 'ignore-prop' which is declared here on type 'IntrinsicAttributes & { prop: number; "ignore-prop": string; }'
     }
    
    // Error
    function Baz<T>(arg: T) {
        let a0 = <ComponentSpecific1 {...arg} />
                  ~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { prop: {}; "ignore-prop": string; }'.
!!! error TS2322:   Type 'T' is not assignable to type '{ prop: {}; "ignore-prop": string; }'.
    }
    
    declare function Link<U>(l: {func: (arg: U)=>void}): JSX.Element;
    
    // Error
    function createLink(func: (a: number, b: string)=>void) {
        let o = <Link func={func} />
                      ~~~~
!!! error TS2322: Type '(a: number, b: string) => void' is not assignable to type '(arg: number) => void'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:16:30: The expected type comes from property 'func' which is declared here on type 'IntrinsicAttributes & { func: (arg: number) => void; }'
    }
    
    interface InferParamProp<T> {
        values: Array<T>;
        selectHandler: (selectedVal: T) => void;
    }
    
    declare function InferParamComponent<T>(attr: InferParamProp<T>): JSX.Element;
    
    // Error
    let i = <InferParamComponent values={[1, 2, 3, 4]} selectHandler={(val: string) => { }} />;
                                                       ~~~~~~~~~~~~~
!!! error TS2322: Type '(val: string) => void' is not assignable to type '(selectedVal: number) => void'.
!!! error TS2322:   Types of parameters 'val' and 'selectedVal' are incompatible.
!!! error TS2322:     Type 'number' is not assignable to type 'string'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:25:5: The expected type comes from property 'selectHandler' which is declared here on type 'IntrinsicAttributes & InferParamProp<number>'