update baselines

This commit is contained in:
Kanchalai Tanglertsampan
2017-04-12 12:17:37 -07:00
parent f0990460a6
commit eb0ad7f3f9
24 changed files with 1714 additions and 13 deletions
@@ -0,0 +1,39 @@
//// [file.tsx]
import React = require('react');
interface Prop {
a: number,
b: string,
children: string | JSX.Element
}
function Comp(p: Prop) {
return <div>{p.b}</div>;
}
// OK
let k = <Comp a={10} b="hi" children ="lol" />;
let k1 =
<Comp a={10} b="hi">
hi hi hi!
</Comp>;
let k2 =
<Comp a={10} b="hi">
<div>hi hi hi!</div>
</Comp>;
//// [file.jsx]
"use strict";
exports.__esModule = true;
var React = require("react");
function Comp(p) {
return <div>{p.b}</div>;
}
// OK
var k = <Comp a={10} b="hi" children="lol"/>;
var k1 = <Comp a={10} b="hi">
hi hi hi!
</Comp>;
var k2 = <Comp a={10} b="hi">
<div>hi hi hi!</div>
</Comp>;
@@ -0,0 +1,67 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
interface Prop {
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
a: number,
>a : Symbol(Prop.a, Decl(file.tsx, 2, 16))
b: string,
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
children: string | JSX.Element
>children : Symbol(Prop.children, Decl(file.tsx, 4, 14))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
}
function Comp(p: Prop) {
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1))
>p : Symbol(p, Decl(file.tsx, 8, 14))
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
return <div>{p.b}</div>;
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
>p : Symbol(p, Decl(file.tsx, 8, 14))
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
}
// OK
let k = <Comp a={10} b="hi" children ="lol" />;
>k : Symbol(k, Decl(file.tsx, 13, 3))
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1))
>a : Symbol(a, Decl(file.tsx, 13, 13))
>b : Symbol(b, Decl(file.tsx, 13, 20))
>children : Symbol(children, Decl(file.tsx, 13, 27))
let k1 =
>k1 : Symbol(k1, Decl(file.tsx, 14, 3))
<Comp a={10} b="hi">
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1))
>a : Symbol(a, Decl(file.tsx, 15, 9))
>b : Symbol(b, Decl(file.tsx, 15, 16))
hi hi hi!
</Comp>;
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1))
let k2 =
>k2 : Symbol(k2, Decl(file.tsx, 18, 3))
<Comp a={10} b="hi">
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1))
>a : Symbol(a, Decl(file.tsx, 19, 9))
>b : Symbol(b, Decl(file.tsx, 19, 16))
<div>hi hi hi!</div>
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
</Comp>;
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1))
@@ -0,0 +1,75 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
interface Prop {
>Prop : Prop
a: number,
>a : number
b: string,
>b : string
children: string | JSX.Element
>children : string | JSX.Element
>JSX : any
>Element : JSX.Element
}
function Comp(p: Prop) {
>Comp : (p: Prop) => JSX.Element
>p : Prop
>Prop : Prop
return <div>{p.b}</div>;
><div>{p.b}</div> : JSX.Element
>div : any
>p.b : string
>p : Prop
>b : string
>div : any
}
// OK
let k = <Comp a={10} b="hi" children ="lol" />;
>k : JSX.Element
><Comp a={10} b="hi" children ="lol" /> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
>children : string
let k1 =
>k1 : JSX.Element
<Comp a={10} b="hi">
><Comp a={10} b="hi"> hi hi hi! </Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
hi hi hi!
</Comp>;
>Comp : (p: Prop) => JSX.Element
let k2 =
>k2 : JSX.Element
<Comp a={10} b="hi">
><Comp a={10} b="hi"> <div>hi hi hi!</div> </Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
<div>hi hi hi!</div>
><div>hi hi hi!</div> : JSX.Element
>div : any
>div : any
</Comp>;
>Comp : (p: Prop) => JSX.Element
@@ -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 <div>{p.b}</div>;
}
// Error: missing children
let k = <Comp a={10} b="hi" />;
~~~~~~~~~~~~~
!!! 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 =
<Comp a={10} b="hi" children="Random" >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2708: props.children are specified twice. The attribute named 'children' will be overwritten.
hi hi hi!
</Comp>;
// Error: incorrect type
let k2 =
<Comp a={10} b="hi">
~~~~~~~~~~~~~
!!! 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))[]'.
<div> My Div </div>
{(name: string) => <div> My name {name} </div>}
</Comp>;
let k3 =
<Comp a={10} b="hi">
~~~~~~~~~~~~~
!!! 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)[]'.
<div> My Div </div>
{1000000}
</Comp>;
let k4 =
<Comp a={10} b="hi" >
~~~~~~~~~~~~~
!!! 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)[]'.
<div> My Div </div>
hi hi hi!
</Comp>;
let k5 =
<Comp a={10} b="hi" >
~~~~~~~~~~~~~
!!! 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[]'.
<div> My Div </div>
<div> My Div </div>
</Comp>;
@@ -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 <div>{p.b}</div>;
}
// Error: missing children
let k = <Comp a={10} b="hi" />;
let k1 =
<Comp a={10} b="hi" children="Random" >
hi hi hi!
</Comp>;
// Error: incorrect type
let k2 =
<Comp a={10} b="hi">
<div> My Div </div>
{(name: string) => <div> My name {name} </div>}
</Comp>;
let k3 =
<Comp a={10} b="hi">
<div> My Div </div>
{1000000}
</Comp>;
let k4 =
<Comp a={10} b="hi" >
<div> My Div </div>
hi hi hi!
</Comp>;
let k5 =
<Comp a={10} b="hi" >
<div> My Div </div>
<div> My Div </div>
</Comp>;
//// [file.jsx]
"use strict";
exports.__esModule = true;
var React = require("react");
function Comp(p) {
return <div>{p.b}</div>;
}
// Error: missing children
var k = <Comp a={10} b="hi"/>;
var k1 = <Comp a={10} b="hi" children="Random">
hi hi hi!
</Comp>;
// Error: incorrect type
var k2 = <Comp a={10} b="hi">
<div> My Div </div>
{function (name) { return <div> My name {name} </div>; }}
</Comp>;
var k3 = <Comp a={10} b="hi">
<div> My Div </div>
{1000000}
</Comp>;
var k4 = <Comp a={10} b="hi">
<div> My Div </div>
hi hi hi!
</Comp>;
var k5 = <Comp a={10} b="hi">
<div> My Div </div>
<div> My Div </div>
</Comp>;
@@ -0,0 +1,79 @@
//// [file.tsx]
import React = require('react');
interface IUser {
Name: string;
}
interface IFetchUserProps {
children: (user: IUser) => JSX.Element;
}
class FetchUser extends React.Component<IFetchUserProps, any> {
render() {
return this.state
? this.props.children(this.state.result)
: null;
}
}
// Ok
function UserName0() {
return (
<FetchUser>
{ user => (
<h1>{ user.Name }</h1>
) }
</FetchUser>
);
}
function UserName1() {
return (
<FetchUser>
{ user => (
<h1>{ user.Name }</h1>
) }
</FetchUser>
);
}
//// [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 FetchUser = (function (_super) {
__extends(FetchUser, _super);
function FetchUser() {
return _super !== null && _super.apply(this, arguments) || this;
}
FetchUser.prototype.render = function () {
return this.state
? this.props.children(this.state.result)
: null;
};
return FetchUser;
}(React.Component));
// Ok
function UserName0() {
return (<FetchUser>
{function (user) { return (<h1>{user.Name}</h1>); }}
</FetchUser>);
}
function UserName1() {
return (<FetchUser>
{function (user) { return (<h1>{user.Name}</h1>); }}
</FetchUser>);
}
@@ -0,0 +1,99 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
interface IUser {
>IUser : Symbol(IUser, Decl(file.tsx, 0, 32))
Name: string;
>Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17))
}
interface IFetchUserProps {
>IFetchUserProps : Symbol(IFetchUserProps, Decl(file.tsx, 4, 1))
children: (user: IUser) => JSX.Element;
>children : Symbol(IFetchUserProps.children, Decl(file.tsx, 6, 27))
>user : Symbol(user, Decl(file.tsx, 7, 15))
>IUser : Symbol(IUser, Decl(file.tsx, 0, 32))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
}
class FetchUser extends React.Component<IFetchUserProps, any> {
>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1))
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>React : Symbol(React, Decl(file.tsx, 0, 0))
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>IFetchUserProps : Symbol(IFetchUserProps, Decl(file.tsx, 4, 1))
render() {
>render : Symbol(FetchUser.render, Decl(file.tsx, 10, 63))
return this.state
>this.state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44))
>this : Symbol(FetchUser, Decl(file.tsx, 8, 1))
>state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44))
? this.props.children(this.state.result)
>this.props.children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 173, 20))
>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
>this : Symbol(FetchUser, Decl(file.tsx, 8, 1))
>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
>children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 173, 20))
>this.state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44))
>this : Symbol(FetchUser, Decl(file.tsx, 8, 1))
>state : Symbol(React.Component.state, Decl(react.d.ts, 173, 44))
: null;
}
}
// Ok
function UserName0() {
>UserName0 : Symbol(UserName0, Decl(file.tsx, 16, 1))
return (
<FetchUser>
>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1))
{ user => (
>user : Symbol(user, Decl(file.tsx, 22, 13))
<h1>{ user.Name }</h1>
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
>user.Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17))
>user : Symbol(user, Decl(file.tsx, 22, 13))
>Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17))
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
) }
</FetchUser>
>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1))
);
}
function UserName1() {
>UserName1 : Symbol(UserName1, Decl(file.tsx, 27, 1))
return (
<FetchUser>
>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1))
{ user => (
>user : Symbol(user, Decl(file.tsx, 33, 13))
<h1>{ user.Name }</h1>
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
>user.Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17))
>user : Symbol(user, Decl(file.tsx, 33, 13))
>Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17))
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
) }
</FetchUser>
>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1))
);
}
@@ -0,0 +1,116 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
interface IUser {
>IUser : IUser
Name: string;
>Name : string
}
interface IFetchUserProps {
>IFetchUserProps : IFetchUserProps
children: (user: IUser) => JSX.Element;
>children : (user: IUser) => JSX.Element
>user : IUser
>IUser : IUser
>JSX : any
>Element : JSX.Element
}
class FetchUser extends React.Component<IFetchUserProps, any> {
>FetchUser : FetchUser
>React.Component : React.Component<IFetchUserProps, any>
>React : typeof React
>Component : typeof React.Component
>IFetchUserProps : IFetchUserProps
render() {
>render : () => JSX.Element
return this.state
>this.state ? this.props.children(this.state.result) : null : JSX.Element
>this.state : any
>this : this
>state : any
? this.props.children(this.state.result)
>this.props.children(this.state.result) : JSX.Element
>this.props.children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & React.ReactElement<any>) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement<any>)[])
>this.props : IFetchUserProps & { children?: React.ReactNode; }
>this : this
>props : IFetchUserProps & { children?: React.ReactNode; }
>children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & React.ReactElement<any>) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement<any>)[])
>this.state.result : any
>this.state : any
>this : this
>state : any
>result : any
: null;
>null : null
}
}
// Ok
function UserName0() {
>UserName0 : () => JSX.Element
return (
>( <FetchUser> { user => ( <h1>{ user.Name }</h1> ) } </FetchUser> ) : JSX.Element
<FetchUser>
><FetchUser> { user => ( <h1>{ user.Name }</h1> ) } </FetchUser> : JSX.Element
>FetchUser : typeof FetchUser
{ user => (
>user => ( <h1>{ user.Name }</h1> ) : (user: IUser) => JSX.Element
>user : IUser
>( <h1>{ user.Name }</h1> ) : JSX.Element
<h1>{ user.Name }</h1>
><h1>{ user.Name }</h1> : JSX.Element
>h1 : any
>user.Name : string
>user : IUser
>Name : string
>h1 : any
) }
</FetchUser>
>FetchUser : typeof FetchUser
);
}
function UserName1() {
>UserName1 : () => JSX.Element
return (
>( <FetchUser> { user => ( <h1>{ user.Name }</h1> ) } </FetchUser> ) : JSX.Element
<FetchUser>
><FetchUser> { user => ( <h1>{ user.Name }</h1> ) } </FetchUser> : JSX.Element
>FetchUser : typeof FetchUser
{ user => (
>user => ( <h1>{ user.Name }</h1> ) : (user: IUser) => JSX.Element
>user : IUser
>( <h1>{ user.Name }</h1> ) : JSX.Element
<h1>{ user.Name }</h1>
><h1>{ user.Name }</h1> : JSX.Element
>h1 : any
>user.Name : string
>user : IUser
>Name : string
>h1 : any
) }
</FetchUser>
>FetchUser : typeof FetchUser
);
}
@@ -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<FetchUser> & 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<IFetchUserProps, any> {
render() {
return this.state
? this.props.children(this.state.result)
: null;
}
}
// Error
function UserName() {
return (
<FetchUser>
{ user => (
<h1>{ user.NAme }</h1>
~~~~
!!! error TS2339: Property 'NAme' does not exist on type 'IUser'.
) }
</FetchUser>
);
}
function UserName1() {
return (
<FetchUser>
~~~~~~~~~~~
!!! error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<FetchUser> & 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 => (
<h1>{ user.Name }</h1>
) }
{ user => (
<h1>{ user.Name }</h1>
) }
</FetchUser>
);
}
@@ -0,0 +1,87 @@
//// [file.tsx]
import React = require('react');
interface IUser {
Name: string;
}
interface IFetchUserProps {
children: (user: IUser) => JSX.Element;
}
class FetchUser extends React.Component<IFetchUserProps, any> {
render() {
return this.state
? this.props.children(this.state.result)
: null;
}
}
// Error
function UserName() {
return (
<FetchUser>
{ user => (
<h1>{ user.NAme }</h1>
) }
</FetchUser>
);
}
function UserName1() {
return (
<FetchUser>
{ user => (
<h1>{ user.Name }</h1>
) }
{ user => (
<h1>{ user.Name }</h1>
) }
</FetchUser>
);
}
//// [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 FetchUser = (function (_super) {
__extends(FetchUser, _super);
function FetchUser() {
return _super !== null && _super.apply(this, arguments) || this;
}
FetchUser.prototype.render = function () {
return this.state
? this.props.children(this.state.result)
: null;
};
return FetchUser;
}(React.Component));
// Error
function UserName() {
return (<FetchUser>
{function (user) { return (<h1>{user.NAme}</h1>); }}
</FetchUser>);
}
function UserName1() {
return (<FetchUser>
{function (user) { return (<h1>{user.Name}</h1>); }}
{function (user) { return (<h1>{user.Name}</h1>); }}
</FetchUser>);
}
@@ -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<any, any> {
render() {
return (<div>My Button</div>)
}
}
function Comp(p: Prop) {
return <div>{p.b}</div>;
}
// Error: no children specified
let k = <Comp a={10} b="hi" />;
~~~~~~~~~~~~~
!!! 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 =
<Comp a={10} b="hi">
~~~~~~~~~~~~~
!!! 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'.
<Button />
</Comp>;
let k2 =
<Comp a={10} b="hi">
~~~~~~~~~~~~~
!!! 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}
</Comp>;
@@ -0,0 +1,68 @@
//// [file.tsx]
import React = require('react');
interface Prop {
a: number,
b: string,
children: Button;
}
class Button extends React.Component<any, any> {
render() {
return (<div>My Button</div>)
}
}
function Comp(p: Prop) {
return <div>{p.b}</div>;
}
// Error: no children specified
let k = <Comp a={10} b="hi" />;
// Error: JSX.element is not the same as JSX.ElementClass
let k1 =
<Comp a={10} b="hi">
<Button />
</Comp>;
let k2 =
<Comp a={10} b="hi">
{Button}
</Comp>;
//// [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 (<div>My Button</div>);
};
return Button;
}(React.Component));
function Comp(p) {
return <div>{p.b}</div>;
}
// Error: no children specified
var k = <Comp a={10} b="hi"/>;
// Error: JSX.element is not the same as JSX.ElementClass
var k1 = <Comp a={10} b="hi">
<Button />
</Comp>;
var k2 = <Comp a={10} b="hi">
{Button}
</Comp>;
@@ -0,0 +1,91 @@
//// [file.tsx]
import React = require('react');
interface Prop {
a: number,
b: string,
children: JSX.Element | JSX.Element[];
}
class Button extends React.Component<any, any> {
render() {
return (<div>My Button</div>)
}
}
function AnotherButton(p: any) {
return <h1>Just Another Button</h1>;
}
function Comp(p: Prop) {
return <div>{p.b}</div>;
}
// Ok
let k1 =
<Comp a={10} b="hi">
<Button />
<AnotherButton />
</Comp>;
let k2 =
<Comp a={10} b="hi">
<Button />
<AnotherButton />
</Comp>;
let k3 = <Comp a={10} b="hi"><Button />
<AnotherButton />
</Comp>;
let k4 = <Comp a={10} b="hi"><Button /></Comp>;
//// [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 (<div>My Button</div>);
};
return Button;
}(React.Component));
function AnotherButton(p) {
return <h1>Just Another Button</h1>;
}
function Comp(p) {
return <div>{p.b}</div>;
}
// Ok
var k1 = <Comp a={10} b="hi">
<Button />
<AnotherButton />
</Comp>;
var k2 = <Comp a={10} b="hi">
<Button />
<AnotherButton />
</Comp>;
var k3 = <Comp a={10} b="hi"><Button />
<AnotherButton />
</Comp>;
var k4 = <Comp a={10} b="hi"><Button /></Comp>;
@@ -0,0 +1,116 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
interface Prop {
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
a: number,
>a : Symbol(Prop.a, Decl(file.tsx, 2, 16))
b: string,
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
children: JSX.Element | JSX.Element[];
>children : Symbol(Prop.children, Decl(file.tsx, 4, 14))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
}
class Button extends React.Component<any, any> {
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>React : Symbol(React, Decl(file.tsx, 0, 0))
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
render() {
>render : Symbol(Button.render, Decl(file.tsx, 8, 48))
return (<div>My Button</div>)
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
}
}
function AnotherButton(p: any) {
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
>p : Symbol(p, Decl(file.tsx, 14, 23))
return <h1>Just Another Button</h1>;
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
}
function Comp(p: Prop) {
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>p : Symbol(p, Decl(file.tsx, 18, 14))
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
return <div>{p.b}</div>;
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
>p : Symbol(p, Decl(file.tsx, 18, 14))
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
}
// Ok
let k1 =
>k1 : Symbol(k1, Decl(file.tsx, 23, 3))
<Comp a={10} b="hi">
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 24, 9))
>b : Symbol(b, Decl(file.tsx, 24, 16))
<Button />
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
<AnotherButton />
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
</Comp>;
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
let k2 =
>k2 : Symbol(k2, Decl(file.tsx, 29, 3))
<Comp a={10} b="hi">
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 30, 9))
>b : Symbol(b, Decl(file.tsx, 30, 16))
<Button />
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
<AnotherButton />
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
</Comp>;
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
let k3 = <Comp a={10} b="hi"><Button />
>k3 : Symbol(k3, Decl(file.tsx, 38, 3))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 38, 14))
>b : Symbol(b, Decl(file.tsx, 38, 21))
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
<AnotherButton />
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
</Comp>;
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
let k4 = <Comp a={10} b="hi"><Button /></Comp>;
>k4 : Symbol(k4, Decl(file.tsx, 42, 3))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 42, 14))
>b : Symbol(b, Decl(file.tsx, 42, 21))
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
@@ -0,0 +1,135 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
interface Prop {
>Prop : Prop
a: number,
>a : number
b: string,
>b : string
children: JSX.Element | JSX.Element[];
>children : JSX.Element | JSX.Element[]
>JSX : any
>Element : JSX.Element
>JSX : any
>Element : JSX.Element
}
class Button extends React.Component<any, any> {
>Button : Button
>React.Component : React.Component<any, any>
>React : typeof React
>Component : typeof React.Component
render() {
>render : () => JSX.Element
return (<div>My Button</div>)
>(<div>My Button</div>) : JSX.Element
><div>My Button</div> : JSX.Element
>div : any
>div : any
}
}
function AnotherButton(p: any) {
>AnotherButton : (p: any) => JSX.Element
>p : any
return <h1>Just Another Button</h1>;
><h1>Just Another Button</h1> : JSX.Element
>h1 : any
>h1 : any
}
function Comp(p: Prop) {
>Comp : (p: Prop) => JSX.Element
>p : Prop
>Prop : Prop
return <div>{p.b}</div>;
><div>{p.b}</div> : JSX.Element
>div : any
>p.b : string
>p : Prop
>b : string
>div : any
}
// Ok
let k1 =
>k1 : JSX.Element
<Comp a={10} b="hi">
><Comp a={10} b="hi"> <Button /> <AnotherButton /> </Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
<Button />
><Button /> : JSX.Element
>Button : typeof Button
<AnotherButton />
><AnotherButton /> : JSX.Element
>AnotherButton : (p: any) => JSX.Element
</Comp>;
>Comp : (p: Prop) => JSX.Element
let k2 =
>k2 : JSX.Element
<Comp a={10} b="hi">
><Comp a={10} b="hi"> <Button /> <AnotherButton /> </Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
<Button />
><Button /> : JSX.Element
>Button : typeof Button
<AnotherButton />
><AnotherButton /> : JSX.Element
>AnotherButton : (p: any) => JSX.Element
</Comp>;
>Comp : (p: Prop) => JSX.Element
let k3 = <Comp a={10} b="hi"><Button />
>k3 : JSX.Element
><Comp a={10} b="hi"><Button /> <AnotherButton /></Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
><Button /> : JSX.Element
>Button : typeof Button
<AnotherButton />
><AnotherButton /> : JSX.Element
>AnotherButton : (p: any) => JSX.Element
</Comp>;
>Comp : (p: Prop) => JSX.Element
let k4 = <Comp a={10} b="hi"><Button /></Comp>;
>k4 : JSX.Element
><Comp a={10} b="hi"><Button /></Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
><Button /> : JSX.Element
>Button : typeof Button
>Comp : (p: Prop) => JSX.Element
@@ -0,0 +1,68 @@
tests/cases/conformance/jsx/file.tsx(24,16): 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 'Element | Element[]'.
Type '(string | Element)[]' is not assignable to type 'Element[]'.
Type 'string | Element' is not assignable to type 'Element'.
Type 'string' is not assignable to type 'Element'.
tests/cases/conformance/jsx/file.tsx(25,16): 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 'Element | Element[]'.
Type '(string | Element)[]' is not assignable to type 'Element[]'.
tests/cases/conformance/jsx/file.tsx(27,16): 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 'Element | Element[]'.
Type '(string | Element)[]' is not assignable to type 'Element[]'.
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
import React = require('react');
interface Prop {
a: number,
b: string,
children: JSX.Element | JSX.Element[];
}
class Button extends React.Component<any, any> {
render() {
return (<div>My Button</div>)
}
}
function AnotherButton(p: any) {
return <h1>Just Another Button</h1>;
}
function Comp(p: Prop) {
return <div>{p.b}</div>;
}
// Error: whitespaces matters
let k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
~~~~~~~~~~~~~
!!! 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 = <Comp a={10} b="hi"><Button />
~~~~~~~~~~~~~
!!! 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[]'.
<AnotherButton /> </Comp>;
let k3 = <Comp a={10} b="hi"> <Button />
~~~~~~~~~~~~~
!!! 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[]'.
<AnotherButton /></Comp>;
@@ -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<any, any> {
render() {
return (<div>My Button</div>)
}
}
function AnotherButton(p: any) {
return <h1>Just Another Button</h1>;
}
function Comp(p: Prop) {
return <div>{p.b}</div>;
}
// Error: whitespaces matters
let k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
let k2 = <Comp a={10} b="hi"><Button />
<AnotherButton /> </Comp>;
let k3 = <Comp a={10} b="hi"> <Button />
<AnotherButton /></Comp>;
//// [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 (<div>My Button</div>);
};
return Button;
}(React.Component));
function AnotherButton(p) {
return <h1>Just Another Button</h1>;
}
function Comp(p) {
return <div>{p.b}</div>;
}
// Error: whitespaces matters
var k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
var k2 = <Comp a={10} b="hi"><Button />
<AnotherButton /> </Comp>;
var k3 = <Comp a={10} b="hi"> <Button />
<AnotherButton /></Comp>;
@@ -0,0 +1,69 @@
//// [file.tsx]
import React = require('react');
interface Prop {
a: number,
b: string,
children: string | JSX.Element | (string | JSX.Element)[];
}
class Button extends React.Component<any, any> {
render() {
return (<div>My Button</div>)
}
}
function AnotherButton(p: any) {
return <h1>Just Another Button</h1>;
}
function Comp(p: Prop) {
return <div>{p.b}</div>;
}
// OK
let k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
let k2 = <Comp a={10} b="hi"><Button />
<AnotherButton /> </Comp>;
let k3 = <Comp a={10} b="hi"> <Button />
<AnotherButton /></Comp>;
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
//// [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 (<div>My Button</div>);
};
return Button;
}(React.Component));
function AnotherButton(p) {
return <h1>Just Another Button</h1>;
}
function Comp(p) {
return <div>{p.b}</div>;
}
// OK
var k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
var k2 = <Comp a={10} b="hi"><Button />
<AnotherButton /> </Comp>;
var k3 = <Comp a={10} b="hi"> <Button />
<AnotherButton /></Comp>;
var k4 = <Comp a={10} b="hi"><Button /> </Comp>;
@@ -0,0 +1,98 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
interface Prop {
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
a: number,
>a : Symbol(Prop.a, Decl(file.tsx, 2, 16))
b: string,
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
children: string | JSX.Element | (string | JSX.Element)[];
>children : Symbol(Prop.children, Decl(file.tsx, 4, 14))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
}
class Button extends React.Component<any, any> {
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>React : Symbol(React, Decl(file.tsx, 0, 0))
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
render() {
>render : Symbol(Button.render, Decl(file.tsx, 8, 48))
return (<div>My Button</div>)
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
}
}
function AnotherButton(p: any) {
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
>p : Symbol(p, Decl(file.tsx, 14, 23))
return <h1>Just Another Button</h1>;
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
}
function Comp(p: Prop) {
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>p : Symbol(p, Decl(file.tsx, 18, 14))
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
return <div>{p.b}</div>;
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
>p : Symbol(p, Decl(file.tsx, 18, 14))
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
}
// OK
let k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
>k1 : Symbol(k1, Decl(file.tsx, 23, 3))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 23, 14))
>b : Symbol(b, Decl(file.tsx, 23, 21))
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
let k2 = <Comp a={10} b="hi"><Button />
>k2 : Symbol(k2, Decl(file.tsx, 24, 3))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 24, 14))
>b : Symbol(b, Decl(file.tsx, 24, 21))
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
<AnotherButton /> </Comp>;
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
let k3 = <Comp a={10} b="hi"> <Button />
>k3 : Symbol(k3, Decl(file.tsx, 26, 3))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 26, 14))
>b : Symbol(b, Decl(file.tsx, 26, 21))
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
<AnotherButton /></Comp>;
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
>k4 : Symbol(k4, Decl(file.tsx, 28, 3))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
>a : Symbol(a, Decl(file.tsx, 28, 14))
>b : Symbol(b, Decl(file.tsx, 28, 21))
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
@@ -0,0 +1,117 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
interface Prop {
>Prop : Prop
a: number,
>a : number
b: string,
>b : string
children: string | JSX.Element | (string | JSX.Element)[];
>children : string | JSX.Element | (string | JSX.Element)[]
>JSX : any
>Element : JSX.Element
>JSX : any
>Element : JSX.Element
}
class Button extends React.Component<any, any> {
>Button : Button
>React.Component : React.Component<any, any>
>React : typeof React
>Component : typeof React.Component
render() {
>render : () => JSX.Element
return (<div>My Button</div>)
>(<div>My Button</div>) : JSX.Element
><div>My Button</div> : JSX.Element
>div : any
>div : any
}
}
function AnotherButton(p: any) {
>AnotherButton : (p: any) => JSX.Element
>p : any
return <h1>Just Another Button</h1>;
><h1>Just Another Button</h1> : JSX.Element
>h1 : any
>h1 : any
}
function Comp(p: Prop) {
>Comp : (p: Prop) => JSX.Element
>p : Prop
>Prop : Prop
return <div>{p.b}</div>;
><div>{p.b}</div> : JSX.Element
>div : any
>p.b : string
>p : Prop
>b : string
>div : any
}
// OK
let k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
>k1 : JSX.Element
><Comp a={10} b="hi"><Button /> <AnotherButton /></Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
><Button /> : JSX.Element
>Button : typeof Button
><AnotherButton /> : JSX.Element
>AnotherButton : (p: any) => JSX.Element
>Comp : (p: Prop) => JSX.Element
let k2 = <Comp a={10} b="hi"><Button />
>k2 : JSX.Element
><Comp a={10} b="hi"><Button /> <AnotherButton /> </Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
><Button /> : JSX.Element
>Button : typeof Button
<AnotherButton /> </Comp>;
><AnotherButton /> : JSX.Element
>AnotherButton : (p: any) => JSX.Element
>Comp : (p: Prop) => JSX.Element
let k3 = <Comp a={10} b="hi"> <Button />
>k3 : JSX.Element
><Comp a={10} b="hi"> <Button /> <AnotherButton /></Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
><Button /> : JSX.Element
>Button : typeof Button
<AnotherButton /></Comp>;
><AnotherButton /> : JSX.Element
>AnotherButton : (p: any) => JSX.Element
>Comp : (p: Prop) => JSX.Element
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
>k4 : JSX.Element
><Comp a={10} b="hi"><Button /> </Comp> : JSX.Element
>Comp : (p: Prop) => JSX.Element
>a : number
>10 : 10
>b : string
><Button /> : JSX.Element
>Button : typeof Button
>Comp : (p: Prop) => JSX.Element
@@ -1,7 +1,9 @@
tests/cases/conformance/jsx/file.tsx(48,24): error TS2322: Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
tests/cases/conformance/jsx/file.tsx(49,24): error TS2322: Type '{ to: string; onClick: (e: any) => void; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
tests/cases/conformance/jsx/file.tsx(48,24): error TS2322: Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }' is not assignable to type 'HyphenProps'.
Property '"data-format"' is missing in type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }'.
tests/cases/conformance/jsx/file.tsx(49,24): error TS2322: Type '{ to: string; onClick: (e: any) => void; children: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
Type '{ to: string; onClick: (e: any) => void; children: string; }' is not assignable to type 'HyphenProps'.
Property '"data-format"' is missing in type '{ to: string; onClick: (e: any) => void; children: string; }'.
tests/cases/conformance/jsx/file.tsx(50,24): error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
Property 'onClick' does not exist on type 'IntrinsicAttributes & HyphenProps'.
tests/cases/conformance/jsx/file.tsx(51,24): error TS2322: Type '{ onClick: (k: MouseEvent<any>) => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
@@ -68,12 +70,14 @@ tests/cases/conformance/jsx/file.tsx(56,24): error TS2322: Type '{ data-format:
// Error
const b0 = <MainButton to='/some/path' onClick={(e)=>{}}>GO</MainButton>; // extra property;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
!!! error TS2322: Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
!!! error TS2322: Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
!!! error TS2322: Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }' is not assignable to type 'HyphenProps'.
!!! error TS2322: Property '"data-format"' is missing in type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }'.
const b1 = <MainButton onClick={(e: any)=> {}} {...obj0}>Hello world</MainButton>; // extra property;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ to: string; onClick: (e: any) => void; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
!!! error TS2322: Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
!!! error TS2322: Type '{ to: string; onClick: (e: any) => void; children: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
!!! error TS2322: Type '{ to: string; onClick: (e: any) => void; children: string; }' is not assignable to type 'HyphenProps'.
!!! error TS2322: Property '"data-format"' is missing in type '{ to: string; onClick: (e: any) => void; children: string; }'.
const b2 = <MainButton {...{to: "10000"}} {...obj2} />; // extra property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
@@ -50,7 +50,7 @@ const b6 = <MainButton {...obj2} />;
const b7 = <MainButton {...{onClick: () => { console.log("hi") }}} />;
const b8 = <MainButton {...{onClick() {}}} />; // OK; method declaration get retained (See GitHub #13365)
const b9 = <MainButton to='/some/path' extra-prop>GO</MainButton>;
const b10 = <MainButton to='/some/path' children="hi" >GO</MainButton>;
const b10 = <MainButton to='/some/path' children="hi" ></MainButton>;
const b11 = <MainButton onClick={(e) => {}} className="hello" data-format>Hello world</MainButton>;
const b12 = <MainButton data-format="Hello world" />
@@ -88,7 +88,7 @@ define(["require", "exports", "react"], function (require, exports, React) {
var b7 = <MainButton {...{ onClick: function () { console.log("hi"); } }}/>;
var b8 = <MainButton {...{ onClick: function () { } }}/>; // OK; method declaration get retained (See GitHub #13365)
var b9 = <MainButton to='/some/path' extra-prop>GO</MainButton>;
var b10 = <MainButton to='/some/path' children="hi">GO</MainButton>;
var b10 = <MainButton to='/some/path' children="hi"></MainButton>;
var b11 = <MainButton onClick={function (e) { }} className="hello" data-format>Hello world</MainButton>;
var b12 = <MainButton data-format="Hello world"/>;
});
@@ -165,7 +165,7 @@ const b9 = <MainButton to='/some/path' extra-prop>GO</MainButton>;
>extra-prop : Symbol(extra-prop, Decl(file.tsx, 50, 38))
>MainButton : Symbol(MainButton, Decl(file.tsx, 26, 1), Decl(file.tsx, 28, 66), Decl(file.tsx, 29, 62), Decl(file.tsx, 30, 66))
const b10 = <MainButton to='/some/path' children="hi" >GO</MainButton>;
const b10 = <MainButton to='/some/path' children="hi" ></MainButton>;
>b10 : Symbol(b10, Decl(file.tsx, 51, 5))
>MainButton : Symbol(MainButton, Decl(file.tsx, 26, 1), Decl(file.tsx, 28, 66), Decl(file.tsx, 29, 62), Decl(file.tsx, 30, 66))
>to : Symbol(to, Decl(file.tsx, 51, 23))
@@ -197,9 +197,9 @@ const b9 = <MainButton to='/some/path' extra-prop>GO</MainButton>;
>extra-prop : true
>MainButton : { (buttonProps: ButtonProps): JSX.Element; (linkProps: LinkProps): JSX.Element; (hyphenProps: HyphenProps): JSX.Element; }
const b10 = <MainButton to='/some/path' children="hi" >GO</MainButton>;
const b10 = <MainButton to='/some/path' children="hi" ></MainButton>;
>b10 : JSX.Element
><MainButton to='/some/path' children="hi" >GO</MainButton> : JSX.Element
><MainButton to='/some/path' children="hi" ></MainButton> : JSX.Element
>MainButton : { (buttonProps: ButtonProps): JSX.Element; (linkProps: LinkProps): JSX.Element; (hyphenProps: HyphenProps): JSX.Element; }
>to : string
>children : string