Skip to content

Commit 64d301b

Browse files
author
Yui T
committed
Updates tests and baselines
1 parent ddd5351 commit 64d301b

14 files changed

+391
-40
lines changed

tests/baselines/reference/checkJsxChildrenProperty12.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ interface ButtonProp {
99

1010
class Button extends React.Component<ButtonProp, any> {
1111
render() {
12-
return <InnerButton {...this.props} />
12+
let condition: boolean;
13+
if (condition) {
14+
return <InnerButton {...this.props} />
15+
}
16+
else {
17+
return (<InnerButton {...this.props} >
18+
<div>Hello World</div>
19+
</InnerButton>);
20+
}
1321
}
1422
}
1523

@@ -44,7 +52,15 @@ var Button = (function (_super) {
4452
return _super !== null && _super.apply(this, arguments) || this;
4553
}
4654
Button.prototype.render = function () {
47-
return <InnerButton {...this.props}/>;
55+
var condition;
56+
if (condition) {
57+
return <InnerButton {...this.props}/>;
58+
}
59+
else {
60+
return (<InnerButton {...this.props}>
61+
<div>Hello World</div>
62+
</InnerButton>);
63+
}
4864
};
4965
return Button;
5066
}(React.Component));

tests/baselines/reference/checkJsxChildrenProperty12.symbols

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,51 @@ class Button extends React.Component<ButtonProp, any> {
2626
render() {
2727
>render : Symbol(Button.render, Decl(file.tsx, 8, 55))
2828

29-
return <InnerButton {...this.props} />
30-
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 16, 1))
29+
let condition: boolean;
30+
>condition : Symbol(condition, Decl(file.tsx, 10, 5))
31+
32+
if (condition) {
33+
>condition : Symbol(condition, Decl(file.tsx, 10, 5))
34+
35+
return <InnerButton {...this.props} />
36+
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
3137
>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
3238
>this : Symbol(Button, Decl(file.tsx, 6, 1))
3339
>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
40+
}
41+
else {
42+
return (<InnerButton {...this.props} >
43+
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
44+
>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
45+
>this : Symbol(Button, Decl(file.tsx, 6, 1))
46+
>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
47+
48+
<div>Hello World</div>
49+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45))
50+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45))
51+
52+
</InnerButton>);
53+
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
54+
}
3455
}
3556
}
3657

3758
interface InnerButtonProp {
38-
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 12, 1))
59+
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 20, 1))
3960

4061
a: number
41-
>a : Symbol(InnerButtonProp.a, Decl(file.tsx, 14, 27))
62+
>a : Symbol(InnerButtonProp.a, Decl(file.tsx, 22, 27))
4263
}
4364

4465
class InnerButton extends React.Component<InnerButtonProp, any> {
45-
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 16, 1))
66+
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
4667
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
4768
>React : Symbol(React, Decl(file.tsx, 0, 0))
4869
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
49-
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 12, 1))
70+
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 20, 1))
5071

5172
render() {
52-
>render : Symbol(InnerButton.render, Decl(file.tsx, 18, 65))
73+
>render : Symbol(InnerButton.render, Decl(file.tsx, 26, 65))
5374

5475
return (<button>Hello</button>);
5576
>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43))

tests/baselines/reference/checkJsxChildrenProperty12.types

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,36 @@ class Button extends React.Component<ButtonProp, any> {
2626
render() {
2727
>render : () => JSX.Element
2828

29-
return <InnerButton {...this.props} />
29+
let condition: boolean;
30+
>condition : boolean
31+
32+
if (condition) {
33+
>condition : boolean
34+
35+
return <InnerButton {...this.props} />
3036
><InnerButton {...this.props} /> : JSX.Element
3137
>InnerButton : typeof InnerButton
3238
>this.props : ButtonProp & { children?: React.ReactNode; }
3339
>this : this
3440
>props : ButtonProp & { children?: React.ReactNode; }
41+
}
42+
else {
43+
return (<InnerButton {...this.props} >
44+
>(<InnerButton {...this.props} > <div>Hello World</div> </InnerButton>) : JSX.Element
45+
><InnerButton {...this.props} > <div>Hello World</div> </InnerButton> : JSX.Element
46+
>InnerButton : typeof InnerButton
47+
>this.props : ButtonProp & { children?: React.ReactNode; }
48+
>this : this
49+
>props : ButtonProp & { children?: React.ReactNode; }
50+
51+
<div>Hello World</div>
52+
><div>Hello World</div> : JSX.Element
53+
>div : any
54+
>div : any
55+
56+
</InnerButton>);
57+
>InnerButton : typeof InnerButton
58+
}
3559
}
3660
}
3761

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
tests/cases/conformance/jsx/file.tsx(12,30): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
2+
3+
4+
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
5+
import React = require('react');
6+
7+
interface ButtonProp {
8+
a: number,
9+
b: string,
10+
children: Button;
11+
}
12+
13+
class Button extends React.Component<ButtonProp, any> {
14+
render() {
15+
// Error children are specified twice
16+
return (<InnerButton {...this.props} children="hi">
17+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18+
!!! error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
19+
<div>Hello World</div>
20+
</InnerButton>);
21+
}
22+
}
23+
24+
interface InnerButtonProp {
25+
a: number
26+
}
27+
28+
class InnerButton extends React.Component<InnerButtonProp, any> {
29+
render() {
30+
return (<button>Hello</button>);
31+
}
32+
}
33+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//// [file.tsx]
2+
import React = require('react');
3+
4+
interface ButtonProp {
5+
a: number,
6+
b: string,
7+
children: Button;
8+
}
9+
10+
class Button extends React.Component<ButtonProp, any> {
11+
render() {
12+
// Error children are specified twice
13+
return (<InnerButton {...this.props} children="hi">
14+
<div>Hello World</div>
15+
</InnerButton>);
16+
}
17+
}
18+
19+
interface InnerButtonProp {
20+
a: number
21+
}
22+
23+
class InnerButton extends React.Component<InnerButtonProp, any> {
24+
render() {
25+
return (<button>Hello</button>);
26+
}
27+
}
28+
29+
30+
//// [file.jsx]
31+
"use strict";
32+
var __extends = (this && this.__extends) || (function () {
33+
var extendStatics = Object.setPrototypeOf ||
34+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
35+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
36+
return function (d, b) {
37+
extendStatics(d, b);
38+
function __() { this.constructor = d; }
39+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40+
};
41+
})();
42+
exports.__esModule = true;
43+
var React = require("react");
44+
var Button = (function (_super) {
45+
__extends(Button, _super);
46+
function Button() {
47+
return _super !== null && _super.apply(this, arguments) || this;
48+
}
49+
Button.prototype.render = function () {
50+
// Error children are specified twice
51+
return (<InnerButton {...this.props} children="hi">
52+
<div>Hello World</div>
53+
</InnerButton>);
54+
};
55+
return Button;
56+
}(React.Component));
57+
var InnerButton = (function (_super) {
58+
__extends(InnerButton, _super);
59+
function InnerButton() {
60+
return _super !== null && _super.apply(this, arguments) || this;
61+
}
62+
InnerButton.prototype.render = function () {
63+
return (<button>Hello</button>);
64+
};
65+
return InnerButton;
66+
}(React.Component));

tests/baselines/reference/tsxSpreadAttributesResolution13.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ interface ComponentProps {
77
}
88

99
export default function Component(props: ComponentProps) {
10-
return (
11-
<AnotherComponent {...props} />
12-
);
10+
let condition1: boolean;
11+
if (condition1) {
12+
return (
13+
<ChildComponent {...props} />
14+
);
15+
}
16+
else {
17+
return (<ChildComponent {...props} property1="NewString" />);
18+
}
1319
}
1420

1521
interface AnotherComponentProps {
1622
property1: string;
1723
}
1824

19-
function AnotherComponent({ property1 }: AnotherComponentProps) {
25+
function ChildComponent({ property1 }: AnotherComponentProps) {
2026
return (
2127
<span>{property1}</span>
2228
);
@@ -27,10 +33,16 @@ function AnotherComponent({ property1 }: AnotherComponentProps) {
2733
exports.__esModule = true;
2834
var React = require("react");
2935
function Component(props) {
30-
return (<AnotherComponent {...props}/>);
36+
var condition1;
37+
if (condition1) {
38+
return (<ChildComponent {...props}/>);
39+
}
40+
else {
41+
return (<ChildComponent {...props} property1="NewString"/>);
42+
}
3143
}
3244
exports["default"] = Component;
33-
function AnotherComponent(_a) {
45+
function ChildComponent(_a) {
3446
var property1 = _a.property1;
3547
return (<span>{property1}</span>);
3648
}

tests/baselines/reference/tsxSpreadAttributesResolution13.symbols

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,43 @@ export default function Component(props: ComponentProps) {
1717
>props : Symbol(props, Decl(file.tsx, 7, 34))
1818
>ComponentProps : Symbol(ComponentProps, Decl(file.tsx, 0, 32))
1919

20-
return (
21-
<AnotherComponent {...props} />
22-
>AnotherComponent : Symbol(AnotherComponent, Decl(file.tsx, 15, 1))
20+
let condition1: boolean;
21+
>condition1 : Symbol(condition1, Decl(file.tsx, 8, 7))
22+
23+
if (condition1) {
24+
>condition1 : Symbol(condition1, Decl(file.tsx, 8, 7))
25+
26+
return (
27+
<ChildComponent {...props} />
28+
>ChildComponent : Symbol(ChildComponent, Decl(file.tsx, 21, 1))
2329
>props : Symbol(props, Decl(file.tsx, 7, 34))
2430

25-
);
31+
);
32+
}
33+
else {
34+
return (<ChildComponent {...props} property1="NewString" />);
35+
>ChildComponent : Symbol(ChildComponent, Decl(file.tsx, 21, 1))
36+
>props : Symbol(props, Decl(file.tsx, 7, 34))
37+
>property1 : Symbol(property1, Decl(file.tsx, 15, 42))
38+
}
2639
}
2740

2841
interface AnotherComponentProps {
29-
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 11, 1))
42+
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 17, 1))
3043

3144
property1: string;
32-
>property1 : Symbol(AnotherComponentProps.property1, Decl(file.tsx, 13, 33))
45+
>property1 : Symbol(AnotherComponentProps.property1, Decl(file.tsx, 19, 33))
3346
}
3447

35-
function AnotherComponent({ property1 }: AnotherComponentProps) {
36-
>AnotherComponent : Symbol(AnotherComponent, Decl(file.tsx, 15, 1))
37-
>property1 : Symbol(property1, Decl(file.tsx, 17, 27))
38-
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 11, 1))
48+
function ChildComponent({ property1 }: AnotherComponentProps) {
49+
>ChildComponent : Symbol(ChildComponent, Decl(file.tsx, 21, 1))
50+
>property1 : Symbol(property1, Decl(file.tsx, 23, 25))
51+
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 17, 1))
3952

4053
return (
4154
<span>{property1}</span>
4255
>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2460, 51))
43-
>property1 : Symbol(property1, Decl(file.tsx, 17, 27))
56+
>property1 : Symbol(property1, Decl(file.tsx, 23, 25))
4457
>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2460, 51))
4558

4659
);

tests/baselines/reference/tsxSpreadAttributesResolution13.types

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,30 @@ export default function Component(props: ComponentProps) {
1717
>props : ComponentProps
1818
>ComponentProps : ComponentProps
1919

20-
return (
21-
>( <AnotherComponent {...props} /> ) : JSX.Element
20+
let condition1: boolean;
21+
>condition1 : boolean
22+
23+
if (condition1) {
24+
>condition1 : boolean
25+
26+
return (
27+
>( <ChildComponent {...props} /> ) : JSX.Element
2228

23-
<AnotherComponent {...props} />
24-
><AnotherComponent {...props} /> : JSX.Element
25-
>AnotherComponent : ({property1}: AnotherComponentProps) => JSX.Element
29+
<ChildComponent {...props} />
30+
><ChildComponent {...props} /> : JSX.Element
31+
>ChildComponent : ({property1}: AnotherComponentProps) => JSX.Element
2632
>props : ComponentProps
2733

28-
);
34+
);
35+
}
36+
else {
37+
return (<ChildComponent {...props} property1="NewString" />);
38+
>(<ChildComponent {...props} property1="NewString" />) : JSX.Element
39+
><ChildComponent {...props} property1="NewString" /> : JSX.Element
40+
>ChildComponent : ({property1}: AnotherComponentProps) => JSX.Element
41+
>props : ComponentProps
42+
>property1 : string
43+
}
2944
}
3045

3146
interface AnotherComponentProps {
@@ -35,8 +50,8 @@ interface AnotherComponentProps {
3550
>property1 : string
3651
}
3752

38-
function AnotherComponent({ property1 }: AnotherComponentProps) {
39-
>AnotherComponent : ({property1}: AnotherComponentProps) => JSX.Element
53+
function ChildComponent({ property1 }: AnotherComponentProps) {
54+
>ChildComponent : ({property1}: AnotherComponentProps) => JSX.Element
4055
>property1 : string
4156
>AnotherComponentProps : AnotherComponentProps
4257

0 commit comments

Comments
 (0)