Skip to content

Commit cddaf9f

Browse files
Andaristuhyo
andauthored
Port "fix: do not use JSX.ElementChildrenAttribute under jsx: react-jsx or jsx: react-jsxdev" (#1067)
Co-authored-by: uhyo <[email protected]>
1 parent 9d1bafa commit cddaf9f

9 files changed

+14
-222
lines changed

internal/checker/jsx.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,10 @@ func (c *Checker) getJsxElementPropertiesName(jsxNamespace *ast.Symbol) string {
10771077
}
10781078

10791079
func (c *Checker) getJsxElementChildrenPropertyName(jsxNamespace *ast.Symbol) string {
1080+
if c.compilerOptions.Jsx == core.JsxEmitReactJSX || c.compilerOptions.Jsx == core.JsxEmitReactJSXDev {
1081+
// In these JsxEmit modes the children property is fixed to 'children'
1082+
return "children"
1083+
}
10801084
return c.getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace)
10811085
}
10821086

testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
2-
/test.tsx(3,2): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
3-
/test.tsx(5,50): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
1+
/test.tsx(7,2): error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'.
42

53

64
==== /jsx.d.ts (0 errors) ====
@@ -16,23 +14,17 @@
1614
}
1715
}
1816

19-
==== /test.tsx (3 errors) ====
17+
==== /test.tsx (1 errors) ====
2018
const Title = (props: { children: string }) => <h1>{props.children}</h1>;
21-
~~
22-
!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
23-
!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here.
2419

2520
<Title>Hello, world!</Title>;
26-
~~~~~
27-
!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
28-
!!! related TS2728 /test.tsx:1:25: 'children' is declared here.
2921

3022
const Wrong = (props: { offspring: string }) => <h1>{props.offspring}</h1>;
31-
~~
32-
!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
33-
!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here.
3423

3524
<Wrong>Byebye, world!</Wrong>
25+
~~~~~
26+
!!! error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'.
27+
!!! related TS2728 /test.tsx:5:25: 'offspring' is declared here.
3628

3729
==== /jsx/jsx-runtime.ts (0 errors) ====
3830
export {};

testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt.diff

Lines changed: 0 additions & 38 deletions
This file was deleted.

testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
2-
/test.tsx(3,2): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
3-
/test.tsx(5,50): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
1+
/test.tsx(7,2): error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'.
42

53

64
==== /jsx.d.ts (0 errors) ====
@@ -16,23 +14,17 @@
1614
}
1715
}
1816

19-
==== /test.tsx (3 errors) ====
17+
==== /test.tsx (1 errors) ====
2018
const Title = (props: { children: string }) => <h1>{props.children}</h1>;
21-
~~
22-
!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
23-
!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here.
2419

2520
<Title>Hello, world!</Title>;
26-
~~~~~
27-
!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
28-
!!! related TS2728 /test.tsx:1:25: 'children' is declared here.
2921

3022
const Wrong = (props: { offspring: string }) => <h1>{props.offspring}</h1>;
31-
~~
32-
!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'.
33-
!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here.
3423

3524
<Wrong>Byebye, world!</Wrong>
25+
~~~~~
26+
!!! error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'.
27+
!!! related TS2728 /test.tsx:5:25: 'offspring' is declared here.
3628

3729
==== /jsx/jsx-runtime.ts (0 errors) ====
3830
export {};

testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt.diff

Lines changed: 0 additions & 38 deletions
This file was deleted.

testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt.diff

Lines changed: 0 additions & 32 deletions
This file was deleted.

testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt

Lines changed: 0 additions & 28 deletions
This file was deleted.

testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt.diff

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)