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
Skip IntrinsicAttributes elaboration in JSX errors (microsoft#24461)
* Skip IntrinsicAttributes elaboration in JSX errors
Do not issue an error message for a source type that comes from JSX
attributes and a target type that is an intersection containing
IntrinsicAttributes or IntrinsicClassAttributes. This will make error
messages simpler and less confusing.
Note:
1. There will always be elaboration under the skipped message, so this
won't elide errors completely.
2. Rarely (once in the tests) the intersection type will have more that
one non-Intrinsic* member. However, these additional members don't
provide useful information either, so it's fine to skip them.
* Add test of IntrinsicAttributes error
* Fix indentation in test
Copy file name to clipboardExpand all lines: tests/baselines/reference/checkJsxChildrenProperty14.errors.txt
+8-10Lines changed: 8 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,7 @@
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
-
Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
3
-
Types of property 'children' are incompatible.
4
-
Type 'Element[]' is not assignable to type 'Element'.
5
-
Property 'type' is missing in type 'Element[]'.
1
+
tests/cases/conformance/jsx/file.tsx(42,11): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'SingleChildProp'.
2
+
Types of property 'children' are incompatible.
3
+
Type 'Element[]' is not assignable to type 'Element'.
tests/cases/conformance/jsx/file.tsx(14,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
2
-
Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
3
-
Property 'children' is missing in type '{ a: number; b: string; }'.
1
+
tests/cases/conformance/jsx/file.tsx(14,10): error TS2322: Type '{ a: number; b: string; }' is not assignable to type 'Prop'.
2
+
Property 'children' is missing in type '{ a: number; b: string; }'.
4
3
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,6): error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
6
-
Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
7
-
Types of property 'children' are incompatible.
8
-
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
9
-
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
10
-
Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
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
-
Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
13
-
Types of property 'children' are incompatible.
14
-
Type '(number | Element)[]' is not assignable to type 'string | Element'.
15
-
Type '(number | Element)[]' is not assignable to type 'Element'.
16
-
Property 'type' is missing in type '(number | Element)[]'.
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
-
Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
19
-
Types of property 'children' are incompatible.
20
-
Type '(string | Element)[]' is not assignable to type 'string | Element'.
21
-
Type '(string | Element)[]' is not assignable to type 'Element'.
22
-
Property 'type' is missing in type '(string | Element)[]'.
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
-
Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
25
-
Types of property 'children' are incompatible.
26
-
Type 'Element[]' is not assignable to type 'string | Element'.
27
-
Type 'Element[]' is not assignable to type 'Element'.
28
-
Property 'type' is missing in type 'Element[]'.
4
+
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 'Prop'.
5
+
Types of property 'children' are incompatible.
6
+
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
7
+
Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
8
+
Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
9
+
tests/cases/conformance/jsx/file.tsx(37,6): error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
10
+
Types of property 'children' are incompatible.
11
+
Type '(number | Element)[]' is not assignable to type 'string | Element'.
12
+
Type '(number | Element)[]' is not assignable to type 'Element'.
13
+
Property 'type' is missing in type '(number | Element)[]'.
14
+
tests/cases/conformance/jsx/file.tsx(43,6): error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
15
+
Types of property 'children' are incompatible.
16
+
Type '(string | Element)[]' is not assignable to type 'string | Element'.
17
+
Type '(string | Element)[]' is not assignable to type 'Element'.
18
+
Property 'type' is missing in type '(string | Element)[]'.
19
+
tests/cases/conformance/jsx/file.tsx(49,6): error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
20
+
Types of property 'children' are incompatible.
21
+
Type 'Element[]' is not assignable to type 'string | Element'.
22
+
Type 'Element[]' is not assignable to type 'Element'.
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
71
-
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
72
-
!!! error TS2322: Types of property 'children' are incompatible.
73
-
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
74
-
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
75
-
!!! error TS2322: Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
64
+
!!! error TS2322: Type '{ children: (Element | ((name: string) => Element))[]; a: number; b: string; }' is not assignable to type 'Prop'.
65
+
!!! error TS2322: Types of property 'children' are incompatible.
66
+
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
67
+
!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
68
+
!!! error TS2322: Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
76
69
<div> My Div </div>
77
70
{(name: string) => <div> My name {name} </div>}
78
71
</Comp>;
79
72
80
73
let k3 =
81
74
<Comp a={10} b="hi">
82
75
~~~~
83
-
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
84
-
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
85
-
!!! error TS2322: Types of property 'children' are incompatible.
86
-
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'string | Element'.
87
-
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'Element'.
88
-
!!! error TS2322: Property 'type' is missing in type '(number | Element)[]'.
76
+
!!! error TS2322: Type '{ children: (number | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
77
+
!!! error TS2322: Types of property 'children' are incompatible.
78
+
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'string | Element'.
79
+
!!! error TS2322: Type '(number | Element)[]' is not assignable to type 'Element'.
80
+
!!! error TS2322: Property 'type' is missing in type '(number | Element)[]'.
89
81
<div> My Div </div>
90
82
{1000000}
91
83
</Comp>;
92
84
93
85
let k4 =
94
86
<Comp a={10} b="hi" >
95
87
~~~~
96
-
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
97
-
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
98
-
!!! error TS2322: Types of property 'children' are incompatible.
99
-
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'string | Element'.
100
-
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element'.
101
-
!!! error TS2322: Property 'type' is missing in type '(string | Element)[]'.
88
+
!!! error TS2322: Type '{ children: (string | Element)[]; a: number; b: string; }' is not assignable to type 'Prop'.
89
+
!!! error TS2322: Types of property 'children' are incompatible.
90
+
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'string | Element'.
91
+
!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element'.
92
+
!!! error TS2322: Property 'type' is missing in type '(string | Element)[]'.
102
93
<div> My Div </div>
103
94
hi hi hi!
104
95
</Comp>;
105
96
106
97
let k5 =
107
98
<Comp a={10} b="hi" >
108
99
~~~~
109
-
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'IntrinsicAttributes & Prop'.
110
-
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
111
-
!!! error TS2322: Types of property 'children' are incompatible.
112
-
!!! error TS2322: Type 'Element[]' is not assignable to type 'string | Element'.
113
-
!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
114
-
!!! error TS2322: Property 'type' is missing in type 'Element[]'.
100
+
!!! error TS2322: Type '{ children: Element[]; a: number; b: string; }' is not assignable to type 'Prop'.
101
+
!!! error TS2322: Types of property 'children' are incompatible.
102
+
!!! error TS2322: Type 'Element[]' is not assignable to type 'string | Element'.
103
+
!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
104
+
!!! error TS2322: Property 'type' is missing in type 'Element[]'.
Copy file name to clipboardExpand all lines: tests/baselines/reference/checkJsxChildrenProperty4.errors.txt
+8-10Lines changed: 8 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
1
tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'?
2
-
tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<FetchUser> & IFetchUserProps & { children?: ReactNode; }'.
3
-
Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IFetchUserProps'.
4
-
Types of property 'children' are incompatible.
5
-
Type '((user: IUser) => Element)[]' is not assignable to type '(user: IUser) => Element'.
6
-
Type '((user: IUser) => Element)[]' provides no match for the signature '(user: IUser): Element'.
2
+
tests/cases/conformance/jsx/file.tsx(32,10): error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IFetchUserProps'.
3
+
Types of property 'children' are incompatible.
4
+
Type '((user: IUser) => Element)[]' is not assignable to type '(user: IUser) => Element'.
5
+
Type '((user: IUser) => Element)[]' provides no match for the signature '(user: IUser): Element'.
0 commit comments