: JSX.Element
+>div : any
+>div : any
+
+ ;
+>Comp : (p: Prop) => JSX.Element
+
diff --git a/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt
new file mode 100644
index 00000000000..d3639d6783e
--- /dev/null
+++ b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt
@@ -0,0 +1,109 @@
+tests/cases/conformance/jsx/file.tsx(14,15): error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'.
+ Property 'children' is missing in type '{ a: 10; b: "hi"; }'.
+tests/cases/conformance/jsx/file.tsx(17,11): error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
+tests/cases/conformance/jsx/file.tsx(23,11): error TS2322: Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'Prop'.
+ Types of property 'children' are incompatible.
+ Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
+ Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
+ Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
+tests/cases/conformance/jsx/file.tsx(29,11): error TS2322: Type '{ a: 10; b: "hi"; children: (Element | 1000000)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; children: (Element | 1000000)[]; }' is not assignable to type 'Prop'.
+ Types of property 'children' are incompatible.
+ Type '(Element | 1000000)[]' is not assignable to type 'string | Element'.
+ Type '(Element | 1000000)[]' is not assignable to type 'Element'.
+ Property 'type' is missing in type '(Element | 1000000)[]'.
+tests/cases/conformance/jsx/file.tsx(35,11): error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'Prop'.
+ Types of property 'children' are incompatible.
+ Type '(string | Element)[]' is not assignable to type 'string | Element'.
+ Type '(string | Element)[]' is not assignable to type 'Element'.
+ Property 'type' is missing in type '(string | Element)[]'.
+tests/cases/conformance/jsx/file.tsx(41,11): error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'Prop'.
+ Types of property 'children' are incompatible.
+ Type 'Element[]' is not assignable to type 'string | Element'.
+ Type 'Element[]' is not assignable to type 'Element'.
+ Property 'type' is missing in type 'Element[]'.
+
+
+==== tests/cases/conformance/jsx/file.tsx (6 errors) ====
+ import React = require('react');
+
+ interface Prop {
+ a: number,
+ b: string,
+ children: string | JSX.Element
+ }
+
+ function Comp(p: Prop) {
+ return
{p.b}
;
+ }
+
+ // Error: missing children
+ let k = ;
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'.
+!!! error TS2322: Property 'children' is missing in type '{ a: 10; b: "hi"; }'.
+
+ let k1 =
+
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
+ hi hi hi!
+ ;
+
+ // Error: incorrect type
+ let k2 =
+
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'string | Element'.
+!!! error TS2322: Type '(Element | ((name: string) => Element))[]' is not assignable to type 'Element'.
+!!! error TS2322: Property 'type' is missing in type '(Element | ((name: string) => Element))[]'.
+
My Div
+ {(name: string) =>
My name {name}
}
+ ;
+
+ let k3 =
+
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (Element | 1000000)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (Element | 1000000)[]; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type '(Element | 1000000)[]' is not assignable to type 'string | Element'.
+!!! error TS2322: Type '(Element | 1000000)[]' is not assignable to type 'Element'.
+!!! error TS2322: Property 'type' is missing in type '(Element | 1000000)[]'.
+
My Div
+ {1000000}
+ ;
+
+ let k4 =
+
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'string | Element'.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element'.
+!!! error TS2322: Property 'type' is missing in type '(string | Element)[]'.
+
My Div
+ hi hi hi!
+ ;
+
+ let k5 =
+
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type 'Element[]' is not assignable to type 'string | Element'.
+!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
+!!! error TS2322: Property 'type' is missing in type 'Element[]'.
+
My Div
+
My Div
+ ;
\ No newline at end of file
diff --git a/tests/baselines/reference/checkJsxChildrenProperty2.js b/tests/baselines/reference/checkJsxChildrenProperty2.js
new file mode 100644
index 00000000000..3de7333fd6d
--- /dev/null
+++ b/tests/baselines/reference/checkJsxChildrenProperty2.js
@@ -0,0 +1,75 @@
+//// [file.tsx]
+import React = require('react');
+
+interface Prop {
+ a: number,
+ b: string,
+ children: string | JSX.Element
+}
+
+function Comp(p: Prop) {
+ return
{p.b}
;
+}
+
+// Error: missing children
+let k = ;
+
+let k1 =
+
+ hi hi hi!
+ ;
+
+// Error: incorrect type
+let k2 =
+
+
: JSX.Element
+>h1 : any
+>user.Name : string
+>user : IUser
+>Name : string
+>h1 : any
+
+ ) }
+
+>FetchUser : typeof FetchUser
+
+ );
+}
diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt
new file mode 100644
index 00000000000..d12c557102c
--- /dev/null
+++ b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt
@@ -0,0 +1,61 @@
+tests/cases/conformance/jsx/file.tsx(24,28): error TS2339: Property 'NAme' does not exist on type 'IUser'.
+tests/cases/conformance/jsx/file.tsx(32,9): error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & IFetchUserProps & { children?: ReactNode; }'.
+ Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IFetchUserProps'.
+ Types of property 'children' are incompatible.
+ Type '((user: IUser) => Element)[]' is not assignable to type '(user: IUser) => Element'.
+ Type '((user: IUser) => Element)[]' provides no match for the signature '(user: IUser): Element'.
+
+
+==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
+ import React = require('react');
+
+ interface IUser {
+ Name: string;
+ }
+
+ interface IFetchUserProps {
+ children: (user: IUser) => JSX.Element;
+ }
+
+ class FetchUser extends React.Component {
+ render() {
+ return this.state
+ ? this.props.children(this.state.result)
+ : null;
+ }
+ }
+
+ // Error
+ function UserName() {
+ return (
+
+ { user => (
+
{ user.NAme }
+ ~~~~
+!!! error TS2339: Property 'NAme' does not exist on type 'IUser'.
+ ) }
+
+ );
+ }
+
+ function UserName1() {
+ return (
+
+ ~~~~~~~~~~~
+!!! error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & IFetchUserProps & { children?: ReactNode; }'.
+!!! error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IFetchUserProps'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type '((user: IUser) => Element)[]' is not assignable to type '(user: IUser) => Element'.
+!!! error TS2322: Type '((user: IUser) => Element)[]' provides no match for the signature '(user: IUser): Element'.
+
+
+
+ { user => (
+
); }}
+ );
+}
diff --git a/tests/baselines/reference/checkJsxChildrenProperty5.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty5.errors.txt
new file mode 100644
index 00000000000..1890bc732d1
--- /dev/null
+++ b/tests/baselines/reference/checkJsxChildrenProperty5.errors.txt
@@ -0,0 +1,62 @@
+tests/cases/conformance/jsx/file.tsx(20,15): error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'.
+ Property 'children' is missing in type '{ a: 10; b: "hi"; }'.
+tests/cases/conformance/jsx/file.tsx(24,11): error TS2322: Type '{ a: 10; b: "hi"; children: Element; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; children: Element; }' is not assignable to type 'Prop'.
+ Types of property 'children' are incompatible.
+ Type 'Element' is not assignable to type 'Button'.
+ Property 'render' is missing in type 'Element'.
+tests/cases/conformance/jsx/file.tsx(28,11): error TS2322: Type '{ a: 10; b: "hi"; children: typeof Button; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+ Type '{ a: 10; b: "hi"; children: typeof Button; }' is not assignable to type 'Prop'.
+ Types of property 'children' are incompatible.
+ Type 'typeof Button' is not assignable to type 'Button'.
+ Property 'render' is missing in type 'typeof Button'.
+
+
+==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
+ import React = require('react');
+
+ interface Prop {
+ a: number,
+ b: string,
+ children: Button;
+ }
+
+ class Button extends React.Component {
+ render() {
+ return (
My Button
)
+ }
+ }
+
+ function Comp(p: Prop) {
+ return
{p.b}
;
+ }
+
+ // Error: no children specified
+ let k = ;
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'.
+!!! error TS2322: Property 'children' is missing in type '{ a: 10; b: "hi"; }'.
+
+ // Error: JSX.element is not the same as JSX.ElementClass
+ let k1 =
+
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: Element; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: Element; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type 'Element' is not assignable to type 'Button'.
+!!! error TS2322: Property 'render' is missing in type 'Element'.
+
+ ;
+ let k2 =
+
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: typeof Button; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: typeof Button; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type 'typeof Button' is not assignable to type 'Button'.
+!!! error TS2322: Property 'render' is missing in type 'typeof Button'.
+ {Button}
+ ;
\ No newline at end of file
diff --git a/tests/baselines/reference/checkJsxChildrenProperty5.js b/tests/baselines/reference/checkJsxChildrenProperty5.js
new file mode 100644
index 00000000000..a08dae2f252
--- /dev/null
+++ b/tests/baselines/reference/checkJsxChildrenProperty5.js
@@ -0,0 +1,68 @@
+//// [file.tsx]
+import React = require('react');
+
+interface Prop {
+ a: number,
+ b: string,
+ children: Button;
+}
+
+class Button extends React.Component {
+ render() {
+ return (
My Button
)
+ }
+}
+
+function Comp(p: Prop) {
+ return
{p.b}
;
+}
+
+// Error: no children specified
+let k = ;
+
+// Error: JSX.element is not the same as JSX.ElementClass
+let k1 =
+
+
+ ;
+let k2 =
+
+ {Button}
+ ;
+
+//// [file.jsx]
+"use strict";
+var __extends = (this && this.__extends) || (function () {
+ var extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+ return function (d, b) {
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+ };
+})();
+exports.__esModule = true;
+var React = require("react");
+var Button = (function (_super) {
+ __extends(Button, _super);
+ function Button() {
+ return _super !== null && _super.apply(this, arguments) || this;
+ }
+ Button.prototype.render = function () {
+ return (
;
+ }
+
+ // Error: whitespaces matters
+ let k1 = ;
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
+!!! error TS2322: Type 'string | Element' is not assignable to type 'Element'.
+!!! error TS2322: Type 'string' is not assignable to type 'Element'.
+ let k2 =
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
+ ;
+ let k3 =
+ ~~~~~~~~~~~~~
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'IntrinsicAttributes & Prop'.
+!!! error TS2322: Type '{ a: 10; b: "hi"; children: (string | Element)[]; }' is not assignable to type 'Prop'.
+!!! error TS2322: Types of property 'children' are incompatible.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element | Element[]'.
+!!! error TS2322: Type '(string | Element)[]' is not assignable to type 'Element[]'.
+ ;
\ No newline at end of file
diff --git a/tests/baselines/reference/checkJsxChildrenProperty7.js b/tests/baselines/reference/checkJsxChildrenProperty7.js
new file mode 100644
index 00000000000..6a82233f0bc
--- /dev/null
+++ b/tests/baselines/reference/checkJsxChildrenProperty7.js
@@ -0,0 +1,66 @@
+//// [file.tsx]
+import React = require('react');
+
+interface Prop {
+ a: number,
+ b: string,
+ children: JSX.Element | JSX.Element[];
+}
+
+class Button extends React.Component {
+ render() {
+ return (