File: tsxAttributeResolution3.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (58 lines) | stat: -rw-r--r-- 2,003 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
tests/cases/conformance/jsx/file.tsx(19,2): error TS2322: Type '{ x: number; }' is not assignable to type 'Attribs1'.
  Types of property 'x' are incompatible.
    Type 'number' is not assignable to type 'string'.
tests/cases/conformance/jsx/file.tsx(23,2): error TS2741: Property 'x' is missing in type '{ y: number; }' but required in type 'Attribs1'.
tests/cases/conformance/jsx/file.tsx(31,8): error TS2322: Type 'number' is not assignable to type 'string'.


==== tests/cases/conformance/jsx/file.tsx (3 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 TS2322: Type '{ x: number; }' is not assignable to type 'Attribs1'.
!!! error TS2322:   Types of property 'x' are incompatible.
!!! error TS2322:     Type 'number' is not assignable to type 'string'.
    
    // Error, x is missing
    var obj3 = { y: 32 };
    <test1 {...obj3} />
     ~~~~~
!!! error TS2741: Property 'x' is missing in type '{ y: number; }' but required in type 'Attribs1'.
!!! related TS2728 tests/cases/conformance/jsx/file.tsx:8:2: 'x' is declared here.
    
    // OK
    var obj4 = { x: 32, y: 32 };
    <test1 {...obj4} x="ok" />
    
    // Error
    var obj5 = { x: 32, y: 32 };
    <test1 x="ok" {...obj5} />
           ~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
!!! related TS6500 tests/cases/conformance/jsx/file.tsx:8:2: The expected type comes from property 'x' which is declared here on type 'Attribs1'
    
    // Ok
    var obj6 = { x: 'ok', y: 32, extra: 100 };
    <test1 {...obj6} />
    
    // OK (spread override)
    var obj7 = { x: 'foo' };
    <test1 x={32} {...obj7} />