diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 80b61edd3657a..4b29a45d09c4d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33466,6 +33466,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getJsxElementChildrenPropertyName(jsxNamespace: Symbol): __String | undefined { + if (compilerOptions.jsx === JsxEmit.ReactJSX || compilerOptions.jsx === JsxEmit.ReactJSXDev) { + // In these JsxEmit modes the children property is fixed to 'children' + return "children" as __String; + } return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt new file mode 100644 index 0000000000000..aab42fbf9bc45 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).errors.txt @@ -0,0 +1,33 @@ +/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) ==== + declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; + + interface ElementChildrenAttribute { + offspring: any; + } + } + +==== /test.tsx (1 errors) ==== + const Title = (props: { children: string }) =>

{props.children}

; + + Hello, world!; + + const Wrong = (props: { offspring: string }) =>

{props.offspring}

; + + 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 {}; +==== /jsx/jsx-dev-runtime.ts (0 errors) ==== + export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js new file mode 100644 index 0000000000000..cacbd70895e97 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx] //// + +//// [jsx.d.ts] +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; + + interface ElementChildrenAttribute { + offspring: any; + } +} + +//// [test.tsx] +const Title = (props: { children: string }) =>

{props.children}

; + +Hello, world!; + +const Wrong = (props: { offspring: string }) =>

{props.offspring}

; + +Byebye, world! + +//// [jsx-runtime.ts] +export {}; +//// [jsx-dev-runtime.ts] +export {}; + + +//// [jsx-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [test.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var jsx_runtime_1 = require("/jsx/jsx-runtime"); +var Title = function (props) { return (0, jsx_runtime_1.jsx)("h1", { children: props.children }); }; +(0, jsx_runtime_1.jsx)(Title, { children: "Hello, world!" }); +var Wrong = function (props) { return (0, jsx_runtime_1.jsx)("h1", { children: props.offspring }); }; +(0, jsx_runtime_1.jsx)(Wrong, { children: "Byebye, world!" }); +//// [jsx-dev-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).symbols b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).symbols new file mode 100644 index 0000000000000..1553edc522be0 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).symbols @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(jsx.d.ts, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsx.d.ts, 0, 23)) + + h1: { children: string } +>h1 : Symbol(IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>children : Symbol(children, Decl(jsx.d.ts, 2, 9)) + } + + type Element = string; +>Element : Symbol(Element, Decl(jsx.d.ts, 3, 3)) + + interface ElementChildrenAttribute { +>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(jsx.d.ts, 5, 24)) + + offspring: any; +>offspring : Symbol(ElementChildrenAttribute.offspring, Decl(jsx.d.ts, 7, 38)) + } +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>props.children : Symbol(children, Decl(test.tsx, 0, 23)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) + +Hello, world!; +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) + +const Wrong = (props: { offspring: string }) =>

{props.offspring}

; +>Wrong : Symbol(Wrong, Decl(test.tsx, 4, 5)) +>props : Symbol(props, Decl(test.tsx, 4, 15)) +>offspring : Symbol(offspring, Decl(test.tsx, 4, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>props.offspring : Symbol(offspring, Decl(test.tsx, 4, 23)) +>props : Symbol(props, Decl(test.tsx, 4, 15)) +>offspring : Symbol(offspring, Decl(test.tsx, 4, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) + +Byebye, world! +>Wrong : Symbol(Wrong, Decl(test.tsx, 4, 5)) +>Wrong : Symbol(Wrong, Decl(test.tsx, 4, 5)) + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; + diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).types b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).types new file mode 100644 index 0000000000000..e25bfcf58bb00 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsx).types @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } +>h1 : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ + } + + type Element = string; +>Element : string +> : ^^^^^^ + + interface ElementChildrenAttribute { + offspring: any; +>offspring : any +> : ^^^ + } +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>(props: { children: string }) =>

{props.children}

: (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>

{props.children}

: string +> : ^^^^^^ +>h1 : any +> : ^^^ +>props.children : string +> : ^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>h1 : any +> : ^^^ + +Hello, world!; +>Hello, world! : string +> : ^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ + +const Wrong = (props: { offspring: string }) =>

{props.offspring}

; +>Wrong : (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>(props: { offspring: string }) =>

{props.offspring}

: (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>props : { offspring: string; } +> : ^^^^^^^^^^^^^ ^^^ +>offspring : string +> : ^^^^^^ +>

{props.offspring}

: string +> : ^^^^^^ +>h1 : any +> : ^^^ +>props.offspring : string +> : ^^^^^^ +>props : { offspring: string; } +> : ^^^^^^^^^^^^^ ^^^ +>offspring : string +> : ^^^^^^ +>h1 : any +> : ^^^ + +Byebye, world! +>Byebye, world! : string +> : ^^^^^^ +>Wrong : (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>Wrong : (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; + diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt new file mode 100644 index 0000000000000..aab42fbf9bc45 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).errors.txt @@ -0,0 +1,33 @@ +/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) ==== + declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; + + interface ElementChildrenAttribute { + offspring: any; + } + } + +==== /test.tsx (1 errors) ==== + const Title = (props: { children: string }) =>

{props.children}

; + + Hello, world!; + + const Wrong = (props: { offspring: string }) =>

{props.offspring}

; + + 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 {}; +==== /jsx/jsx-dev-runtime.ts (0 errors) ==== + export {}; + \ No newline at end of file diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js new file mode 100644 index 0000000000000..58845602a8cfd --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).js @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx] //// + +//// [jsx.d.ts] +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; + + interface ElementChildrenAttribute { + offspring: any; + } +} + +//// [test.tsx] +const Title = (props: { children: string }) =>

{props.children}

; + +Hello, world!; + +const Wrong = (props: { offspring: string }) =>

{props.offspring}

; + +Byebye, world! + +//// [jsx-runtime.ts] +export {}; +//// [jsx-dev-runtime.ts] +export {}; + + +//// [jsx-dev-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [test.js] +"use strict"; +var _this = this; +Object.defineProperty(exports, "__esModule", { value: true }); +var jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); +var _jsxFileName = "/test.tsx"; +var Title = function (props) { return (0, jsx_dev_runtime_1.jsxDEV)("h1", { children: props.children }, void 0, false, { fileName: _jsxFileName, lineNumber: 1, columnNumber: 47 }, _this); }; +(0, jsx_dev_runtime_1.jsxDEV)(Title, { children: "Hello, world!" }, void 0, false, { fileName: _jsxFileName, lineNumber: 1, columnNumber: 74 }, this); +var Wrong = function (props) { return (0, jsx_dev_runtime_1.jsxDEV)("h1", { children: props.offspring }, void 0, false, { fileName: _jsxFileName, lineNumber: 5, columnNumber: 48 }, _this); }; +(0, jsx_dev_runtime_1.jsxDEV)(Wrong, { children: "Byebye, world!" }, void 0, false, { fileName: _jsxFileName, lineNumber: 5, columnNumber: 76 }, this); +//// [jsx-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).symbols b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).symbols new file mode 100644 index 0000000000000..1553edc522be0 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).symbols @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(jsx.d.ts, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsx.d.ts, 0, 23)) + + h1: { children: string } +>h1 : Symbol(IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>children : Symbol(children, Decl(jsx.d.ts, 2, 9)) + } + + type Element = string; +>Element : Symbol(Element, Decl(jsx.d.ts, 3, 3)) + + interface ElementChildrenAttribute { +>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(jsx.d.ts, 5, 24)) + + offspring: any; +>offspring : Symbol(ElementChildrenAttribute.offspring, Decl(jsx.d.ts, 7, 38)) + } +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>props.children : Symbol(children, Decl(test.tsx, 0, 23)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) + +Hello, world!; +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) + +const Wrong = (props: { offspring: string }) =>

{props.offspring}

; +>Wrong : Symbol(Wrong, Decl(test.tsx, 4, 5)) +>props : Symbol(props, Decl(test.tsx, 4, 15)) +>offspring : Symbol(offspring, Decl(test.tsx, 4, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>props.offspring : Symbol(offspring, Decl(test.tsx, 4, 23)) +>props : Symbol(props, Decl(test.tsx, 4, 15)) +>offspring : Symbol(offspring, Decl(test.tsx, 4, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) + +Byebye, world! +>Wrong : Symbol(Wrong, Decl(test.tsx, 4, 5)) +>Wrong : Symbol(Wrong, Decl(test.tsx, 4, 5)) + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; + diff --git a/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).types b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).types new file mode 100644 index 0000000000000..e25bfcf58bb00 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx(jsx=react-jsxdev).types @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } +>h1 : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ + } + + type Element = string; +>Element : string +> : ^^^^^^ + + interface ElementChildrenAttribute { + offspring: any; +>offspring : any +> : ^^^ + } +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>(props: { children: string }) =>

{props.children}

: (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>

{props.children}

: string +> : ^^^^^^ +>h1 : any +> : ^^^ +>props.children : string +> : ^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>h1 : any +> : ^^^ + +Hello, world!; +>Hello, world! : string +> : ^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ + +const Wrong = (props: { offspring: string }) =>

{props.offspring}

; +>Wrong : (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>(props: { offspring: string }) =>

{props.offspring}

: (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>props : { offspring: string; } +> : ^^^^^^^^^^^^^ ^^^ +>offspring : string +> : ^^^^^^ +>

{props.offspring}

: string +> : ^^^^^^ +>h1 : any +> : ^^^ +>props.offspring : string +> : ^^^^^^ +>props : { offspring: string; } +> : ^^^^^^^^^^^^^ ^^^ +>offspring : string +> : ^^^^^^ +>h1 : any +> : ^^^ + +Byebye, world! +>Byebye, world! : string +> : ^^^^^^ +>Wrong : (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>Wrong : (props: { offspring: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; + diff --git a/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js new file mode 100644 index 0000000000000..9ec44be547d1b --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx] //// + +//// [jsx.d.ts] +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; +} + +//// [test.tsx] +const Title = (props: { children: string }) =>

{props.children}

; + +const element = Hello, world!; + +//// [jsx-runtime.ts] +export {}; +//// [jsx-dev-runtime.ts] +export {}; + +//// [jsx-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [test.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var jsx_runtime_1 = require("/jsx/jsx-runtime"); +var Title = function (props) { return (0, jsx_runtime_1.jsx)("h1", { children: props.children }); }; +var element = (0, jsx_runtime_1.jsx)(Title, { children: "Hello, world!" }); +//// [jsx-dev-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).symbols b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).symbols new file mode 100644 index 0000000000000..188816ccf0e27 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).symbols @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(jsx.d.ts, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsx.d.ts, 0, 23)) + + h1: { children: string } +>h1 : Symbol(IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>children : Symbol(children, Decl(jsx.d.ts, 2, 9)) + } + + type Element = string; +>Element : Symbol(Element, Decl(jsx.d.ts, 3, 3)) +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>props.children : Symbol(children, Decl(test.tsx, 0, 23)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) + +const element = Hello, world!; +>element : Symbol(element, Decl(test.tsx, 2, 5)) +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; diff --git a/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).types b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).types new file mode 100644 index 0000000000000..9ed9f010ffb54 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsx).types @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } +>h1 : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ + } + + type Element = string; +>Element : string +> : ^^^^^^ +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>(props: { children: string }) =>

{props.children}

: (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>

{props.children}

: string +> : ^^^^^^ +>h1 : any +> : ^^^ +>props.children : string +> : ^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>h1 : any +> : ^^^ + +const element = Hello, world!; +>element : string +> : ^^^^^^ +>Hello, world! : string +> : ^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; diff --git a/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js new file mode 100644 index 0000000000000..050b784b440fe --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx] //// + +//// [jsx.d.ts] +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; +} + +//// [test.tsx] +const Title = (props: { children: string }) =>

{props.children}

; + +const element = Hello, world!; + +//// [jsx-runtime.ts] +export {}; +//// [jsx-dev-runtime.ts] +export {}; + +//// [jsx-dev-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//// [test.js] +"use strict"; +var _this = this; +Object.defineProperty(exports, "__esModule", { value: true }); +var jsx_dev_runtime_1 = require("/jsx/jsx-dev-runtime"); +var _jsxFileName = "/test.tsx"; +var Title = function (props) { return (0, jsx_dev_runtime_1.jsxDEV)("h1", { children: props.children }, void 0, false, { fileName: _jsxFileName, lineNumber: 1, columnNumber: 47 }, _this); }; +var element = (0, jsx_dev_runtime_1.jsxDEV)(Title, { children: "Hello, world!" }, void 0, false, { fileName: _jsxFileName, lineNumber: 3, columnNumber: 16 }, this); +//// [jsx-runtime.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).symbols b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).symbols new file mode 100644 index 0000000000000..188816ccf0e27 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).symbols @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(jsx.d.ts, 0, 0)) + + interface IntrinsicElements { +>IntrinsicElements : Symbol(IntrinsicElements, Decl(jsx.d.ts, 0, 23)) + + h1: { children: string } +>h1 : Symbol(IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>children : Symbol(children, Decl(jsx.d.ts, 2, 9)) + } + + type Element = string; +>Element : Symbol(Element, Decl(jsx.d.ts, 3, 3)) +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) +>props.children : Symbol(children, Decl(test.tsx, 0, 23)) +>props : Symbol(props, Decl(test.tsx, 0, 15)) +>children : Symbol(children, Decl(test.tsx, 0, 23)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(jsx.d.ts, 1, 31)) + +const element = Hello, world!; +>element : Symbol(element, Decl(test.tsx, 2, 5)) +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) +>Title : Symbol(Title, Decl(test.tsx, 0, 5)) + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; diff --git a/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).types b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).types new file mode 100644 index 0000000000000..9ed9f010ffb54 --- /dev/null +++ b/tests/baselines/reference/jsxNamespaceNoElementChildrenAttributeReactJsx(jsx=react-jsxdev).types @@ -0,0 +1,56 @@ +//// [tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx] //// + +=== /jsx.d.ts === +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } +>h1 : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ + } + + type Element = string; +>Element : string +> : ^^^^^^ +} + +=== /test.tsx === +const Title = (props: { children: string }) =>

{props.children}

; +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>(props: { children: string }) =>

{props.children}

: (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>

{props.children}

: string +> : ^^^^^^ +>h1 : any +> : ^^^ +>props.children : string +> : ^^^^^^ +>props : { children: string; } +> : ^^^^^^^^^^^^ ^^^ +>children : string +> : ^^^^^^ +>h1 : any +> : ^^^ + +const element = Hello, world!; +>element : string +> : ^^^^^^ +>Hello, world! : string +> : ^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ +>Title : (props: { children: string; }) => string +> : ^ ^^ ^^^^^^^^^^^ + +=== /jsx/jsx-runtime.ts === + +export {}; +=== /jsx/jsx-dev-runtime.ts === + +export {}; diff --git a/tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx b/tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx new file mode 100644 index 0000000000000..c06720997c4c7 --- /dev/null +++ b/tests/cases/compiler/jsxNamespaceElementChildrenAttributeIgnoredWhenReactJsx.tsx @@ -0,0 +1,28 @@ +//@jsx: react-jsx,react-jsxdev +//@jsxImportSource: /jsx +//@filename: /jsx.d.ts +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; + + interface ElementChildrenAttribute { + offspring: any; + } +} + +//@filename: /test.tsx +const Title = (props: { children: string }) =>

{props.children}

; + +Hello, world!; + +const Wrong = (props: { offspring: string }) =>

{props.offspring}

; + +Byebye, world! + +//@filename: /jsx/jsx-runtime.ts +export {}; +//@filename: /jsx/jsx-dev-runtime.ts +export {}; diff --git a/tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx b/tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx new file mode 100644 index 0000000000000..49c771606f4a8 --- /dev/null +++ b/tests/cases/compiler/jsxNamespaceNoElementChildrenAttributeReactJsx.tsx @@ -0,0 +1,20 @@ +//@jsx: react-jsx,react-jsxdev +//@jsxImportSource: /jsx +//@filename: /jsx.d.ts +declare namespace JSX { + interface IntrinsicElements { + h1: { children: string } + } + + type Element = string; +} + +//@filename: /test.tsx +const Title = (props: { children: string }) =>

{props.children}

; + +const element = Hello, world!; + +//@filename: /jsx/jsx-runtime.ts +export {}; +//@filename: /jsx/jsx-dev-runtime.ts +export {}; \ No newline at end of file