File: tsxStatelessFunctionComponentsWithTypeArguments2.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 (63 lines) | stat: -rw-r--r-- 4,085 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
tests/cases/conformance/jsx/file.tsx(8,15): error TS2322: Type 'T & { "ignore-prop": number; }' is not assignable to type 'IntrinsicAttributes & { prop: number; "ignore-prop": string; }'.
  Type 'T & { "ignore-prop": number; }' is not assignable to type '{ prop: number; "ignore-prop": string; }'.
    Types of property '"ignore-prop"' are incompatible.
      Type 'number' 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: unknown; "ignore-prop": string; }'.
  Type 'T' is not assignable to type '{ prop: unknown; "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 'T & { "ignore-prop": number; }' is not assignable to type 'IntrinsicAttributes & { prop: number; "ignore-prop": string; }'.
!!! error TS2322:   Type 'T & { "ignore-prop": number; }' is not assignable to type '{ prop: number; "ignore-prop": string; }'.
!!! error TS2322:     Types of property '"ignore-prop"' are incompatible.
!!! error TS2322:       Type 'number' is not assignable to type 'string'.
     }
    
    // Error
    function Baz<T>(arg: T) {
        let a0 = <ComponentSpecific1 {...arg} />
                  ~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'T' is not assignable to type 'IntrinsicAttributes & { prop: unknown; "ignore-prop": string; }'.
!!! error TS2322:   Type 'T' is not assignable to type '{ prop: unknown; "ignore-prop": string; }'.
!!! related TS2208 tests/cases/conformance/jsx/file.tsx:12:14: This type parameter might need an `extends { prop: unknown; "ignore-prop": string; }` constraint.
!!! related TS2208 tests/cases/conformance/jsx/file.tsx:12:14: This type parameter might need an `extends JSX.IntrinsicAttributes & { prop: unknown; "ignore-prop": string; }` constraint.
    }
    
    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>'