Update tests and baselines

This commit is contained in:
Kanchalai Tanglertsampan 2017-04-14 15:23:48 -07:00
parent c778a48703
commit dbf2a96a7e
9 changed files with 112 additions and 18 deletions

View File

@ -27,8 +27,7 @@ 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>;
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
//// [file.jsx]
"use strict";

View File

@ -0,0 +1,16 @@
//// [file.tsx]
import React = require('react');
// OK
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
let k3 = <div> {1} {"That is a number"} </div>;
//// [file.jsx]
"use strict";
exports.__esModule = true;
var React = require("react");
// OK
var k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
var k2 = <div> <h2> Hello </h2> {function (user) { return <h2>{user.name}</h2>; }}</div>;
var k3 = <div> {1} {"That is a number"} </div>;

View File

@ -0,0 +1,30 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
// OK
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
>k1 : Symbol(k1, Decl(file.tsx, 3, 3))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
>k2 : Symbol(k2, Decl(file.tsx, 4, 3))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
>user : Symbol(user, Decl(file.tsx, 4, 34))
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
>user : Symbol(user, Decl(file.tsx, 4, 34))
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
let k3 = <div> {1} {"That is a number"} </div>;
>k3 : Symbol(k3, Decl(file.tsx, 5, 3))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))

View File

@ -0,0 +1,42 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
// OK
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
>k1 : JSX.Element
><div> <h2> Hello </h2> <h1> world </h1></div> : JSX.Element
>div : any
><h2> Hello </h2> : JSX.Element
>h2 : any
>h2 : any
><h1> world </h1> : JSX.Element
>h1 : any
>h1 : any
>div : any
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
>k2 : JSX.Element
><div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div> : JSX.Element
>div : any
><h2> Hello </h2> : JSX.Element
>h2 : any
>h2 : any
>(user: any) => <h2>{user.name}</h2> : (user: any) => JSX.Element
>user : any
><h2>{user.name}</h2> : JSX.Element
>h2 : any
>user.name : any
>user : any
>name : any
>h2 : any
>div : any
let k3 = <div> {1} {"That is a number"} </div>;
>k3 : JSX.Element
><div> {1} {"That is a number"} </div> : JSX.Element
>div : any
>1 : 1
>"That is a number" : "That is a number"
>div : any

View File

@ -33,9 +33,7 @@ tests/cases/conformance/jsx/file.tsx(34,29): error TS2322: Type '{ y1: "hello";
tests/cases/conformance/jsx/file.tsx(35,29): error TS2322: Type '{ y1: "hello"; y2: 1000; children: "hi"; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
Property 'children' does not exist on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'.
Types of property 'y1' are incompatible.
Type '"hello"' is not assignable to type 'boolean'.
Property 'children' does not exist on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
==== tests/cases/conformance/jsx/file.tsx (12 errors) ====
@ -122,7 +120,5 @@ tests/cases/conformance/jsx/file.tsx(36,29): error TS2322: Type '{ y1: "hello";
const e4 = <TestingOptional y1="hello" y2={1000}>Hi</TestingOptional>
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
!!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'.
!!! error TS2322: Types of property 'y1' are incompatible.
!!! error TS2322: Type '"hello"' is not assignable to type 'boolean'.
!!! error TS2322: Property 'children' does not exist on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.

View File

@ -1,9 +1,7 @@
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; }'.
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; 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; }'.
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
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'.
@ -71,13 +69,11 @@ tests/cases/conformance/jsx/file.tsx(56,24): error TS2322: Type '{ data-format:
const b0 = <MainButton to='/some/path' onClick={(e)=>{}}>GO</MainButton>; // extra property;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! 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; }'.
!!! error TS2322: Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
const b1 = <MainButton onClick={(e: any)=> {}} {...obj0}>Hello world</MainButton>; // extra property;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! 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; }'.
!!! error TS2322: Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
const b2 = <MainButton {...{to: "10000"}} {...obj2} />; // extra property
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.

View File

@ -31,4 +31,4 @@ 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>;
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;

View File

@ -0,0 +1,11 @@
// @filename: file.tsx
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
import React = require('react');
// OK
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
let k3 = <div> {1} {"That is a number"} </div>;

View File

@ -2359,7 +2359,11 @@ declare namespace JSX {
interface ElementClass extends React.Component<any, any> {
render(): JSX.Element | null;
}
interface ElementAttributesProperty { props: {}; }
interface ElementAttributesProperty {
props: {
children: any;
};
}
interface IntrinsicAttributes extends React.Attributes { }