From b6f4ed5433f1c4fd18499b0e5833ca5897cbb526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 5 Jun 2025 16:10:11 +0200 Subject: [PATCH] Port "fix: do not use `JSX.ElementChildrenAttribute` under `jsx: react-jsx` or `jsx: react-jsxdev`" Co-authored-by: uhyo --- internal/checker/jsx.go | 4 ++ ...oredWhenReactJsx(jsx=react-jsx).errors.txt | 18 +++------ ...henReactJsx(jsx=react-jsx).errors.txt.diff | 38 ------------------- ...dWhenReactJsx(jsx=react-jsxdev).errors.txt | 18 +++------ ...ReactJsx(jsx=react-jsxdev).errors.txt.diff | 38 ------------------- ...ttributeReactJsx(jsx=react-jsx).errors.txt | 28 -------------- ...uteReactJsx(jsx=react-jsx).errors.txt.diff | 32 ---------------- ...ibuteReactJsx(jsx=react-jsxdev).errors.txt | 28 -------------- ...ReactJsx(jsx=react-jsxdev).errors.txt.diff | 32 ---------------- 9 files changed, 14 insertions(+), 222 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt.diff diff --git a/internal/checker/jsx.go b/internal/checker/jsx.go index 88dde88d10..18666b1c6f 100644 --- a/internal/checker/jsx.go +++ b/internal/checker/jsx.go @@ -1077,6 +1077,10 @@ func (c *Checker) getJsxElementPropertiesName(jsxNamespace *ast.Symbol) string { } func (c *Checker) getJsxElementChildrenPropertyName(jsxNamespace *ast.Symbol) string { + if c.compilerOptions.Jsx == core.JsxEmitReactJSX || c.compilerOptions.Jsx == core.JsxEmitReactJSXDev { + // In these JsxEmit modes the children property is fixed to 'children' + return "children" + } return c.getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace) } diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt index 10c26c5c6b..aab42fbf9b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt @@ -1,6 +1,4 @@ -/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -/test.tsx(3,2): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -/test.tsx(5,50): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. +/test.tsx(7,2): error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. ==== /jsx.d.ts (0 errors) ==== @@ -16,23 +14,17 @@ } } -==== /test.tsx (3 errors) ==== +==== /test.tsx (1 errors) ==== const Title = (props: { children: string }) =>

{props.children}

; - ~~ -!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. Hello, world!; - ~~~~~ -!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -!!! related TS2728 /test.tsx:1:25: 'children' is declared here. const Wrong = (props: { offspring: string }) =>

{props.offspring}

; - ~~ -!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. Byebye, world! + ~~~~~ +!!! error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. +!!! related TS2728 /test.tsx:5:25: 'offspring' is declared here. ==== /jsx/jsx-runtime.ts (0 errors) ==== export {}; diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt.diff deleted file mode 100644 index 3e86f83bb7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt -+++ new.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt -@@= skipped -0, +0 lines =@@ --/test.tsx(7,2): error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. -+/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+/test.tsx(3,2): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+/test.tsx(5,50): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. - - - ==== /jsx.d.ts (0 errors) ==== -@@= skipped -13, +15 lines =@@ - } - } - --==== /test.tsx (1 errors) ==== -+==== /test.tsx (3 errors) ==== - const Title = (props: { children: string }) =>

{props.children}

; -+ ~~ -+!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. - - Hello, world!; -+ ~~~~~ -+!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+!!! related TS2728 /test.tsx:1:25: 'children' is declared here. - - const Wrong = (props: { offspring: string }) =>

{props.offspring}

; -+ ~~ -+!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. - - Byebye, world! -- ~~~~~ --!!! error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. --!!! related TS2728 /test.tsx:5:25: 'offspring' is declared here. - - ==== /jsx/jsx-runtime.ts (0 errors) ==== - export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt index 10c26c5c6b..aab42fbf9b 100644 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt @@ -1,6 +1,4 @@ -/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -/test.tsx(3,2): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -/test.tsx(5,50): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. +/test.tsx(7,2): error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. ==== /jsx.d.ts (0 errors) ==== @@ -16,23 +14,17 @@ } } -==== /test.tsx (3 errors) ==== +==== /test.tsx (1 errors) ==== const Title = (props: { children: string }) =>

{props.children}

; - ~~ -!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. Hello, world!; - ~~~~~ -!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -!!! related TS2728 /test.tsx:1:25: 'children' is declared here. const Wrong = (props: { offspring: string }) =>

{props.offspring}

; - ~~ -!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. Byebye, world! + ~~~~~ +!!! error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. +!!! related TS2728 /test.tsx:5:25: 'offspring' is declared here. ==== /jsx/jsx-runtime.ts (0 errors) ==== export {}; diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt.diff deleted file mode 100644 index 9a0a832e75..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt -+++ new.jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt -@@= skipped -0, +0 lines =@@ --/test.tsx(7,2): error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. -+/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+/test.tsx(3,2): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+/test.tsx(5,50): error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. - - - ==== /jsx.d.ts (0 errors) ==== -@@= skipped -13, +15 lines =@@ - } - } - --==== /test.tsx (1 errors) ==== -+==== /test.tsx (3 errors) ==== - const Title = (props: { children: string }) =>

{props.children}

; -+ ~~ -+!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. - - Hello, world!; -+ ~~~~~ -+!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+!!! related TS2728 /test.tsx:1:25: 'children' is declared here. - - const Wrong = (props: { offspring: string }) =>

{props.offspring}

; -+ ~~ -+!!! error TS2741: Property 'children' is missing in type '{ offspring: string; }' but required in type '{ children: string; }'. -+!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. - - Byebye, world! -- ~~~~~ --!!! error TS2741: Property 'offspring' is missing in type '{ children: string; }' but required in type '{ offspring: string; }'. --!!! related TS2728 /test.tsx:5:25: 'offspring' is declared here. - - ==== /jsx/jsx-runtime.ts (0 errors) ==== - export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt deleted file mode 100644 index ac0895b69a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -/test.tsx(3,18): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. - - -==== /jsx.d.ts (0 errors) ==== - declare namespace JSX { - interface IntrinsicElements { - h1: { children: string } - } - - type Element = string; - } - -==== /test.tsx (2 errors) ==== - const Title = (props: { children: string }) =>

{props.children}

; - ~~ -!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. - - const element = Hello, world!; - ~~~~~ -!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -!!! related TS2728 /test.tsx:1:25: 'children' is declared here. - -==== /jsx/jsx-runtime.ts (0 errors) ==== - export {}; -==== /jsx/jsx-dev-runtime.ts (0 errors) ==== - export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt.diff deleted file mode 100644 index 5804222dad..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt -+++ new.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).errors.txt -@@= skipped -0, +0 lines =@@ -- -+/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+/test.tsx(3,18): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+ -+ -+==== /jsx.d.ts (0 errors) ==== -+ declare namespace JSX { -+ interface IntrinsicElements { -+ h1: { children: string } -+ } -+ -+ type Element = string; -+ } -+ -+==== /test.tsx (2 errors) ==== -+ const Title = (props: { children: string }) =>

{props.children}

; -+ ~~ -+!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. -+ -+ const element = Hello, world!; -+ ~~~~~ -+!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+!!! related TS2728 /test.tsx:1:25: 'children' is declared here. -+ -+==== /jsx/jsx-runtime.ts (0 errors) ==== -+ export {}; -+==== /jsx/jsx-dev-runtime.ts (0 errors) ==== -+ export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt deleted file mode 100644 index ac0895b69a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -/test.tsx(3,18): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. - - -==== /jsx.d.ts (0 errors) ==== - declare namespace JSX { - interface IntrinsicElements { - h1: { children: string } - } - - type Element = string; - } - -==== /test.tsx (2 errors) ==== - const Title = (props: { children: string }) =>

{props.children}

; - ~~ -!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. - - const element = Hello, world!; - ~~~~~ -!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -!!! related TS2728 /test.tsx:1:25: 'children' is declared here. - -==== /jsx/jsx-runtime.ts (0 errors) ==== - export {}; -==== /jsx/jsx-dev-runtime.ts (0 errors) ==== - export {}; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt.diff deleted file mode 100644 index 61f2f5b3c9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt -+++ new.jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).errors.txt -@@= skipped -0, +0 lines =@@ -- -+/test.tsx(1,49): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+/test.tsx(3,18): error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+ -+ -+==== /jsx.d.ts (0 errors) ==== -+ declare namespace JSX { -+ interface IntrinsicElements { -+ h1: { children: string } -+ } -+ -+ type Element = string; -+ } -+ -+==== /test.tsx (2 errors) ==== -+ const Title = (props: { children: string }) =>

{props.children}

; -+ ~~ -+!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+!!! related TS2728 /jsx.d.ts:3:11: 'children' is declared here. -+ -+ const element = Hello, world!; -+ ~~~~~ -+!!! error TS2741: Property 'children' is missing in type '{}' but required in type '{ children: string; }'. -+!!! related TS2728 /test.tsx:1:25: 'children' is declared here. -+ -+==== /jsx/jsx-runtime.ts (0 errors) ==== -+ export {}; -+==== /jsx/jsx-dev-runtime.ts (0 errors) ==== -+ export {}; \ No newline at end of file