You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType.
16199
16199
// This will allow excess properties in spread type as it is very common pattern to spread outer attributes into React component in its render method.
16200
16200
if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) {
@@ -16211,6 +16211,32 @@ namespace ts {
16211
16211
}
16212
16212
}
16213
16213
}
16214
+
else if (!isSourceAttributeTypeAssignableToTarget) {
16215
+
// Assignability failure - check each prop individually, and if that fails, fall back on the bad error span
16216
+
if (length(openingLikeElement.attributes.properties)) {
16217
+
let reportedError = false;
16218
+
for (const prop of openingLikeElement.attributes.properties) {
Copy file name to clipboardExpand all lines: tests/baselines/reference/checkJsxChildrenProperty14.errors.txt
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
tests/cases/conformance/jsx/file.tsx(42,27): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & SingleChildProp'.
1
+
tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & SingleChildProp'.
2
2
Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
3
3
Types of property 'children' are incompatible.
4
4
Type 'Element[]' is not assignable to type 'Element'.
@@ -48,7 +48,7 @@ tests/cases/conformance/jsx/file.tsx(42,27): error TS2322: Type '{ children: Ele
48
48
49
49
// Error
50
50
let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
51
-
~~~~~~~~~~~~~
51
+
~~~~~~~~~~~~~~~
52
52
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & SingleChildProp'.
53
53
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
54
54
!!! error TS2322: Types of property 'children' are incompatible.
Copy file name to clipboardExpand all lines: tests/baselines/reference/checkJsxChildrenProperty2.errors.txt
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,26 @@
1
-
tests/cases/conformance/jsx/file.tsx(14,15): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
1
+
tests/cases/conformance/jsx/file.tsx(14,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
2
2
Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
3
3
Property 'children' is missing in type '{ a: number; b: string; }'.
4
4
tests/cases/conformance/jsx/file.tsx(17,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
5
-
tests/cases/conformance/jsx/file.tsx(31,11): error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
5
+
tests/cases/conformance/jsx/file.tsx(31,6): error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
6
6
Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
7
7
Types of property 'children' are incompatible.
8
8
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
9
9
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
10
10
Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
11
-
tests/cases/conformance/jsx/file.tsx(37,11): error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
11
+
tests/cases/conformance/jsx/file.tsx(37,6): error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
12
12
Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
13
13
Types of property 'children' are incompatible.
14
14
Type '(number | Element)[]' is not assignable to type 'string | Element'.
15
15
Type '(number | Element)[]' is not assignable to type 'Element'.
16
16
Property 'type' is missing in type '(number | Element)[]'.
17
-
tests/cases/conformance/jsx/file.tsx(43,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
17
+
tests/cases/conformance/jsx/file.tsx(43,6): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
18
18
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
19
19
Types of property 'children' are incompatible.
20
20
Type '(string | Element)[]' is not assignable to type 'string | Element'.
21
21
Type '(string | Element)[]' is not assignable to type 'Element'.
22
22
Property 'type' is missing in type '(string | Element)[]'.
23
-
tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
23
+
tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
24
24
Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
25
25
Types of property 'children' are incompatible.
26
26
Type 'Element[]' is not assignable to type 'string | Element'.
@@ -43,7 +43,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ children: Ele
43
43
44
44
// Error: missing children
45
45
let k = <Comp a={10} b="hi" />;
46
-
~~~~~~~~~~~~~
46
+
~~~~
47
47
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
48
48
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
49
49
!!! error TS2322: Property 'children' is missing in type '{ a: number; b: string; }'.
@@ -66,7 +66,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ children: Ele
66
66
// Error: incorrect type
67
67
let k2 =
68
68
<Comp a={10} b="hi">
69
-
~~~~~~~~~~~~~
69
+
~~~~
70
70
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
71
71
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
72
72
!!! error TS2322: Types of property 'children' are incompatible.
@@ -79,7 +79,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ children: Ele
79
79
80
80
let k3 =
81
81
<Comp a={10} b="hi">
82
-
~~~~~~~~~~~~~
82
+
~~~~
83
83
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
84
84
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
85
85
!!! error TS2322: Types of property 'children' are incompatible.
@@ -92,7 +92,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ children: Ele
92
92
93
93
let k4 =
94
94
<Comp a={10} b="hi" >
95
-
~~~~~~~~~~~~~
95
+
~~~~
96
96
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
97
97
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
98
98
!!! error TS2322: Types of property 'children' are incompatible.
@@ -105,7 +105,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ children: Ele
105
105
106
106
let k5 =
107
107
<Comp a={10} b="hi" >
108
-
~~~~~~~~~~~~~
108
+
~~~~
109
109
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
110
110
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
111
111
!!! error TS2322: Types of property 'children' are incompatible.
Copy file name to clipboardExpand all lines: tests/baselines/reference/checkJsxChildrenProperty5.errors.txt
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
tests/cases/conformance/jsx/file.tsx(20,15): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
1
+
tests/cases/conformance/jsx/file.tsx(20,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
2
2
Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
3
3
Property 'children' is missing in type '{ a: number; b: string; }'.
4
-
tests/cases/conformance/jsx/file.tsx(24,11): error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
4
+
tests/cases/conformance/jsx/file.tsx(24,6): error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
5
5
Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
6
6
Types of property 'children' are incompatible.
7
7
Type 'Element' is not assignable to type 'Button'.
8
8
Property 'render' is missing in type 'Element'.
9
-
tests/cases/conformance/jsx/file.tsx(28,11): error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
9
+
tests/cases/conformance/jsx/file.tsx(28,6): error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
10
10
Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
11
11
Types of property 'children' are incompatible.
12
12
Type 'typeof Button' is not assignable to type 'Button'.
@@ -34,15 +34,15 @@ tests/cases/conformance/jsx/file.tsx(28,11): error TS2322: Type '{ children: typ
34
34
35
35
// Error: no children specified
36
36
let k = <Comp a={10} b="hi" />;
37
-
~~~~~~~~~~~~~
37
+
~~~~
38
38
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
39
39
!!! error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
40
40
!!! error TS2322: Property 'children' is missing in type '{ a: number; b: string; }'.
41
41
42
42
// Error: JSX.element is not the same as JSX.ElementClass
43
43
let k1 =
44
44
<Comp a={10} b="hi">
45
-
~~~~~~~~~~~~~
45
+
~~~~
46
46
!!! error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
47
47
!!! error TS2322: Type '{ children: Element; a: number; b: string; }' is not assignable to type 'Prop'.
48
48
!!! error TS2322: Types of property 'children' are incompatible.
@@ -52,7 +52,7 @@ tests/cases/conformance/jsx/file.tsx(28,11): error TS2322: Type '{ children: typ
52
52
</Comp>;
53
53
let k2 =
54
54
<Comp a={10} b="hi">
55
-
~~~~~~~~~~~~~
55
+
~~~~
56
56
!!! error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
57
57
!!! error TS2322: Type '{ children: typeof Button; a: number; b: string; }' is not assignable to type 'Prop'.
58
58
!!! error TS2322: Types of property 'children' are incompatible.
Copy file name to clipboardExpand all lines: tests/baselines/reference/checkJsxChildrenProperty7.errors.txt
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
-
tests/cases/conformance/jsx/file.tsx(24,16): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
1
+
tests/cases/conformance/jsx/file.tsx(24,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
2
2
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
3
3
Types of property 'children' are incompatible.
4
4
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
5
5
Type '(string | Element)[]' is not assignable to type 'Element[]'.
6
6
Type 'string | Element' is not assignable to type 'Element'.
7
7
Type 'string' is not assignable to type 'Element'.
8
-
tests/cases/conformance/jsx/file.tsx(25,16): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
8
+
tests/cases/conformance/jsx/file.tsx(25,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
9
9
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
10
10
Types of property 'children' are incompatible.
11
11
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
12
12
Type '(string | Element)[]' is not assignable to type 'Element[]'.
13
-
tests/cases/conformance/jsx/file.tsx(27,16): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
13
+
tests/cases/conformance/jsx/file.tsx(27,11): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
14
14
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
15
15
Types of property 'children' are incompatible.
16
16
Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
0 commit comments