File: tsxAttributeResolution3.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (59 lines) | stat: -rw-r--r-- 2,006 bytes parent folder | download | duplicates (2)
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
tests/cases/conformance/jsx/file.tsx(19,8): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property.
  Type 'number' is not assignable to type 'string'.
tests/cases/conformance/jsx/file.tsx(23,1): error TS2324: Property 'x' is missing in type 'Attribs1'.
tests/cases/conformance/jsx/file.tsx(31,15): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property.
  Type 'number' is not assignable to type 'string'.
tests/cases/conformance/jsx/file.tsx(39,8): error TS2322: Type '32' is not assignable to type 'string'.


==== tests/cases/conformance/jsx/file.tsx (4 errors) ====
    declare module JSX {
    	interface Element { }
    	interface IntrinsicElements {
    		test1: Attribs1;
    	}
    }
    interface Attribs1 {
    	x: string;
    	y?: number;
    	z?: string;
    }
    
    // OK
    var obj1 = { x: 'foo' };
    <test1 {...obj1} />
    
    // Error, x is not string
    var obj2 = { x: 32 };
    <test1 {...obj2} />
           ~~~~~~~~~
!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property.
!!! error TS2606:   Type 'number' is not assignable to type 'string'.
    
    // Error, x is missing
    var obj3 = { y: 32 };
    <test1 {...obj3} />
    ~~~~~~~~~~~~~~~~~~~
!!! error TS2324: Property 'x' is missing in type 'Attribs1'.
    
    // OK
    var obj4 = { x: 32, y: 32 };
    <test1 {...obj4} x="ok" />
    
    // Error
    var obj5 = { x: 32, y: 32 };
    <test1 x="ok" {...obj5} />
                  ~~~~~~~~~
!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property.
!!! error TS2606:   Type 'number' is not assignable to type 'string'.
    
    // OK
    var obj6 = { x: 'ok', y: 32, extra: 100 };
    <test1 {...obj6} />
    
    // Error
    var obj7 = { x: 'foo' };
    <test1 x={32} {...obj7} />
           ~~~~~~
!!! error TS2322: Type '32' is not assignable to type 'string'.