Skip to content

Commit dbf2a96

Browse files
author
Kanchalai Tanglertsampan
committed
Update tests and baselines
1 parent c778a48 commit dbf2a96

9 files changed

+112
-18
lines changed

tests/baselines/reference/checkJsxChildrenProperty8.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ let k2 = <Comp a={10} b="hi"><Button />
2727
<AnotherButton /> </Comp>;
2828
let k3 = <Comp a={10} b="hi"> <Button />
2929
<AnotherButton /></Comp>;
30-
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
31-
30+
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
3231

3332
//// [file.jsx]
3433
"use strict";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [file.tsx]
2+
import React = require('react');
3+
4+
// OK
5+
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
6+
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
7+
let k3 = <div> {1} {"That is a number"} </div>;
8+
9+
//// [file.jsx]
10+
"use strict";
11+
exports.__esModule = true;
12+
var React = require("react");
13+
// OK
14+
var k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
15+
var k2 = <div> <h2> Hello </h2> {function (user) { return <h2>{user.name}</h2>; }}</div>;
16+
var k3 = <div> {1} {"That is a number"} </div>;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import React = require('react');
3+
>React : Symbol(React, Decl(file.tsx, 0, 0))
4+
5+
// OK
6+
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
7+
>k1 : Symbol(k1, Decl(file.tsx, 3, 3))
8+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
9+
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
10+
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
11+
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
12+
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2407, 47))
13+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
14+
15+
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
16+
>k2 : Symbol(k2, Decl(file.tsx, 4, 3))
17+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
18+
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
19+
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
20+
>user : Symbol(user, Decl(file.tsx, 4, 34))
21+
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
22+
>user : Symbol(user, Decl(file.tsx, 4, 34))
23+
>h2 : Symbol(JSX.IntrinsicElements.h2, Decl(react.d.ts, 2408, 48))
24+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
25+
26+
let k3 = <div> {1} {"That is a number"} </div>;
27+
>k3 : Symbol(k3, Decl(file.tsx, 5, 3))
28+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
29+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2397, 45))
30+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import React = require('react');
3+
>React : typeof React
4+
5+
// OK
6+
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
7+
>k1 : JSX.Element
8+
><div> <h2> Hello </h2> <h1> world </h1></div> : JSX.Element
9+
>div : any
10+
><h2> Hello </h2> : JSX.Element
11+
>h2 : any
12+
>h2 : any
13+
><h1> world </h1> : JSX.Element
14+
>h1 : any
15+
>h1 : any
16+
>div : any
17+
18+
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
19+
>k2 : JSX.Element
20+
><div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div> : JSX.Element
21+
>div : any
22+
><h2> Hello </h2> : JSX.Element
23+
>h2 : any
24+
>h2 : any
25+
>(user: any) => <h2>{user.name}</h2> : (user: any) => JSX.Element
26+
>user : any
27+
><h2>{user.name}</h2> : JSX.Element
28+
>h2 : any
29+
>user.name : any
30+
>user : any
31+
>name : any
32+
>h2 : any
33+
>div : any
34+
35+
let k3 = <div> {1} {"That is a number"} </div>;
36+
>k3 : JSX.Element
37+
><div> {1} {"That is a number"} </div> : JSX.Element
38+
>div : any
39+
>1 : 1
40+
>"That is a number" : "That is a number"
41+
>div : any
42+

tests/baselines/reference/tsxStatelessFunctionComponentOverload4.errors.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ tests/cases/conformance/jsx/file.tsx(34,29): error TS2322: Type '{ y1: "hello";
3333
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; }'.
3434
Property 'children' does not exist on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
3535
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; }'.
36-
Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'.
37-
Types of property 'y1' are incompatible.
38-
Type '"hello"' is not assignable to type 'boolean'.
36+
Property 'children' does not exist on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
3937

4038

4139
==== 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";
122120
const e4 = <TestingOptional y1="hello" y2={1000}>Hi</TestingOptional>
123121
~~~~~~~~~~~~~~~~~~~~
124122
!!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
125-
!!! error TS2322: Type '{ y1: "hello"; y2: 1000; children: string; }' is not assignable to type '{ y1: boolean; y2?: number; y3: boolean; }'.
126-
!!! error TS2322: Types of property 'y1' are incompatible.
127-
!!! error TS2322: Type '"hello"' is not assignable to type 'boolean'.
123+
!!! error TS2322: Property 'children' does not exist on type 'IntrinsicAttributes & { y1: boolean; y2?: number; y3: boolean; }'.
128124

tests/baselines/reference/tsxStatelessFunctionComponentOverload5.errors.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
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'.
2-
Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }' is not assignable to type 'HyphenProps'.
3-
Property '"data-format"' is missing in type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }'.
2+
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
43
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'.
5-
Type '{ to: string; onClick: (e: any) => void; children: string; }' is not assignable to type 'HyphenProps'.
6-
Property '"data-format"' is missing in type '{ to: string; onClick: (e: any) => void; children: string; }'.
4+
Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
75
tests/cases/conformance/jsx/file.tsx(50,24): error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
86
Property 'onClick' does not exist on type 'IntrinsicAttributes & HyphenProps'.
97
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:
7169
const b0 = <MainButton to='/some/path' onClick={(e)=>{}}>GO</MainButton>; // extra property;
7270
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7371
!!! error TS2322: Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
74-
!!! error TS2322: Type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }' is not assignable to type 'HyphenProps'.
75-
!!! error TS2322: Property '"data-format"' is missing in type '{ to: "/some/path"; onClick: (e: MouseEvent<any>) => void; children: string; }'.
72+
!!! error TS2322: Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
7673
const b1 = <MainButton onClick={(e: any)=> {}} {...obj0}>Hello world</MainButton>; // extra property;
7774
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7875
!!! error TS2322: Type '{ to: string; onClick: (e: any) => void; children: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.
79-
!!! error TS2322: Type '{ to: string; onClick: (e: any) => void; children: string; }' is not assignable to type 'HyphenProps'.
80-
!!! error TS2322: Property '"data-format"' is missing in type '{ to: string; onClick: (e: any) => void; children: string; }'.
76+
!!! error TS2322: Property 'to' does not exist on type 'IntrinsicAttributes & HyphenProps'.
8177
const b2 = <MainButton {...{to: "10000"}} {...obj2} />; // extra property
8278
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8379
!!! error TS2322: Type '{ onClick: () => void; to: string; }' is not assignable to type 'IntrinsicAttributes & HyphenProps'.

tests/cases/conformance/jsx/checkJsxChildrenProperty8.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ let k2 = <Comp a={10} b="hi"><Button />
3131
<AnotherButton /> </Comp>;
3232
let k3 = <Comp a={10} b="hi"> <Button />
3333
<AnotherButton /></Comp>;
34-
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
34+
let k4 = <Comp a={10} b="hi"><Button /> </Comp>;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// @filename: file.tsx
2+
// @jsx: preserve
3+
// @noLib: true
4+
// @libFiles: react.d.ts,lib.d.ts
5+
6+
import React = require('react');
7+
8+
// OK
9+
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>;
10+
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>;
11+
let k3 = <div> {1} {"That is a number"} </div>;

tests/lib/react.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,11 @@ declare namespace JSX {
23592359
interface ElementClass extends React.Component<any, any> {
23602360
render(): JSX.Element | null;
23612361
}
2362-
interface ElementAttributesProperty { props: {}; }
2362+
interface ElementAttributesProperty {
2363+
props: {
2364+
children: any;
2365+
};
2366+
}
23632367

23642368
interface IntrinsicAttributes extends React.Attributes { }
23652369

0 commit comments

Comments
 (0)