Skip to content

Commit ddd5351

Browse files
author
Yui T
committed
Add tests and baselines
1 parent 66b0b44 commit ddd5351

15 files changed

+651
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
return <InnerButton {...this.props} />
13+
}
14+
}
15+
16+
interface InnerButtonProp {
17+
a: number
18+
}
19+
20+
class InnerButton extends React.Component<InnerButtonProp, any> {
21+
render() {
22+
return (<button>Hello</button>);
23+
}
24+
}
25+
26+
27+
//// [file.jsx]
28+
"use strict";
29+
var __extends = (this && this.__extends) || (function () {
30+
var extendStatics = Object.setPrototypeOf ||
31+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
32+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
33+
return function (d, b) {
34+
extendStatics(d, b);
35+
function __() { this.constructor = d; }
36+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37+
};
38+
})();
39+
exports.__esModule = true;
40+
var React = require("react");
41+
var Button = (function (_super) {
42+
__extends(Button, _super);
43+
function Button() {
44+
return _super !== null && _super.apply(this, arguments) || this;
45+
}
46+
Button.prototype.render = function () {
47+
return <InnerButton {...this.props}/>;
48+
};
49+
return Button;
50+
}(React.Component));
51+
var InnerButton = (function (_super) {
52+
__extends(InnerButton, _super);
53+
function InnerButton() {
54+
return _super !== null && _super.apply(this, arguments) || this;
55+
}
56+
InnerButton.prototype.render = function () {
57+
return (<button>Hello</button>);
58+
};
59+
return InnerButton;
60+
}(React.Component));
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import React = require('react');
3+
>React : Symbol(React, Decl(file.tsx, 0, 0))
4+
5+
interface ButtonProp {
6+
>ButtonProp : Symbol(ButtonProp, Decl(file.tsx, 0, 32))
7+
8+
a: number,
9+
>a : Symbol(ButtonProp.a, Decl(file.tsx, 2, 22))
10+
11+
b: string,
12+
>b : Symbol(ButtonProp.b, Decl(file.tsx, 3, 14))
13+
14+
children: Button;
15+
>children : Symbol(ButtonProp.children, Decl(file.tsx, 4, 14))
16+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
17+
}
18+
19+
class Button extends React.Component<ButtonProp, any> {
20+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
21+
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
22+
>React : Symbol(React, Decl(file.tsx, 0, 0))
23+
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
24+
>ButtonProp : Symbol(ButtonProp, Decl(file.tsx, 0, 32))
25+
26+
render() {
27+
>render : Symbol(Button.render, Decl(file.tsx, 8, 55))
28+
29+
return <InnerButton {...this.props} />
30+
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 16, 1))
31+
>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
32+
>this : Symbol(Button, Decl(file.tsx, 6, 1))
33+
>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
34+
}
35+
}
36+
37+
interface InnerButtonProp {
38+
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 12, 1))
39+
40+
a: number
41+
>a : Symbol(InnerButtonProp.a, Decl(file.tsx, 14, 27))
42+
}
43+
44+
class InnerButton extends React.Component<InnerButtonProp, any> {
45+
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 16, 1))
46+
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
47+
>React : Symbol(React, Decl(file.tsx, 0, 0))
48+
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
49+
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 12, 1))
50+
51+
render() {
52+
>render : Symbol(InnerButton.render, Decl(file.tsx, 18, 65))
53+
54+
return (<button>Hello</button>);
55+
>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43))
56+
>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43))
57+
}
58+
}
59+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import React = require('react');
3+
>React : typeof React
4+
5+
interface ButtonProp {
6+
>ButtonProp : ButtonProp
7+
8+
a: number,
9+
>a : number
10+
11+
b: string,
12+
>b : string
13+
14+
children: Button;
15+
>children : Button
16+
>Button : Button
17+
}
18+
19+
class Button extends React.Component<ButtonProp, any> {
20+
>Button : Button
21+
>React.Component : React.Component<ButtonProp, any>
22+
>React : typeof React
23+
>Component : typeof React.Component
24+
>ButtonProp : ButtonProp
25+
26+
render() {
27+
>render : () => JSX.Element
28+
29+
return <InnerButton {...this.props} />
30+
><InnerButton {...this.props} /> : JSX.Element
31+
>InnerButton : typeof InnerButton
32+
>this.props : ButtonProp & { children?: React.ReactNode; }
33+
>this : this
34+
>props : ButtonProp & { children?: React.ReactNode; }
35+
}
36+
}
37+
38+
interface InnerButtonProp {
39+
>InnerButtonProp : InnerButtonProp
40+
41+
a: number
42+
>a : number
43+
}
44+
45+
class InnerButton extends React.Component<InnerButtonProp, any> {
46+
>InnerButton : InnerButton
47+
>React.Component : React.Component<InnerButtonProp, any>
48+
>React : typeof React
49+
>Component : typeof React.Component
50+
>InnerButtonProp : InnerButtonProp
51+
52+
render() {
53+
>render : () => JSX.Element
54+
55+
return (<button>Hello</button>);
56+
>(<button>Hello</button>) : JSX.Element
57+
><button>Hello</button> : JSX.Element
58+
>button : any
59+
>button : any
60+
}
61+
}
62+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//// [file.tsx]
2+
import React = require('react');
3+
4+
interface ComponentProps {
5+
property1: string;
6+
property2: number;
7+
}
8+
9+
export default function Component(props: ComponentProps) {
10+
return (
11+
<AnotherComponent {...props} />
12+
);
13+
}
14+
15+
interface AnotherComponentProps {
16+
property1: string;
17+
}
18+
19+
function AnotherComponent({ property1 }: AnotherComponentProps) {
20+
return (
21+
<span>{property1}</span>
22+
);
23+
}
24+
25+
//// [file.jsx]
26+
"use strict";
27+
exports.__esModule = true;
28+
var React = require("react");
29+
function Component(props) {
30+
return (<AnotherComponent {...props}/>);
31+
}
32+
exports["default"] = Component;
33+
function AnotherComponent(_a) {
34+
var property1 = _a.property1;
35+
return (<span>{property1}</span>);
36+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import React = require('react');
3+
>React : Symbol(React, Decl(file.tsx, 0, 0))
4+
5+
interface ComponentProps {
6+
>ComponentProps : Symbol(ComponentProps, Decl(file.tsx, 0, 32))
7+
8+
property1: string;
9+
>property1 : Symbol(ComponentProps.property1, Decl(file.tsx, 2, 26))
10+
11+
property2: number;
12+
>property2 : Symbol(ComponentProps.property2, Decl(file.tsx, 3, 22))
13+
}
14+
15+
export default function Component(props: ComponentProps) {
16+
>Component : Symbol(Component, Decl(file.tsx, 5, 1))
17+
>props : Symbol(props, Decl(file.tsx, 7, 34))
18+
>ComponentProps : Symbol(ComponentProps, Decl(file.tsx, 0, 32))
19+
20+
return (
21+
<AnotherComponent {...props} />
22+
>AnotherComponent : Symbol(AnotherComponent, Decl(file.tsx, 15, 1))
23+
>props : Symbol(props, Decl(file.tsx, 7, 34))
24+
25+
);
26+
}
27+
28+
interface AnotherComponentProps {
29+
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 11, 1))
30+
31+
property1: string;
32+
>property1 : Symbol(AnotherComponentProps.property1, Decl(file.tsx, 13, 33))
33+
}
34+
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))
39+
40+
return (
41+
<span>{property1}</span>
42+
>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2460, 51))
43+
>property1 : Symbol(property1, Decl(file.tsx, 17, 27))
44+
>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2460, 51))
45+
46+
);
47+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import React = require('react');
3+
>React : typeof React
4+
5+
interface ComponentProps {
6+
>ComponentProps : ComponentProps
7+
8+
property1: string;
9+
>property1 : string
10+
11+
property2: number;
12+
>property2 : number
13+
}
14+
15+
export default function Component(props: ComponentProps) {
16+
>Component : (props: ComponentProps) => JSX.Element
17+
>props : ComponentProps
18+
>ComponentProps : ComponentProps
19+
20+
return (
21+
>( <AnotherComponent {...props} /> ) : JSX.Element
22+
23+
<AnotherComponent {...props} />
24+
><AnotherComponent {...props} /> : JSX.Element
25+
>AnotherComponent : ({property1}: AnotherComponentProps) => JSX.Element
26+
>props : ComponentProps
27+
28+
);
29+
}
30+
31+
interface AnotherComponentProps {
32+
>AnotherComponentProps : AnotherComponentProps
33+
34+
property1: string;
35+
>property1 : string
36+
}
37+
38+
function AnotherComponent({ property1 }: AnotherComponentProps) {
39+
>AnotherComponent : ({property1}: AnotherComponentProps) => JSX.Element
40+
>property1 : string
41+
>AnotherComponentProps : AnotherComponentProps
42+
43+
return (
44+
>( <span>{property1}</span> ) : JSX.Element
45+
46+
<span>{property1}</span>
47+
><span>{property1}</span> : JSX.Element
48+
>span : any
49+
>property1 : string
50+
>span : any
51+
52+
);
53+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
tests/cases/conformance/jsx/file.tsx(11,38): error TS2339: Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'.
2+
3+
4+
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
5+
import React = require('react');
6+
7+
interface ComponentProps {
8+
property1: string;
9+
property2: number;
10+
}
11+
12+
export default function Component(props: ComponentProps) {
13+
return (
14+
// Error extra property
15+
<AnotherComponent {...props} Property1/>
16+
~~~~~~~~~
17+
!!! error TS2339: Property 'Property1' does not exist on type 'IntrinsicAttributes & AnotherComponentProps'.
18+
);
19+
}
20+
21+
interface AnotherComponentProps {
22+
property1: string;
23+
}
24+
25+
function AnotherComponent({ property1 }: AnotherComponentProps) {
26+
return (
27+
<span>{property1}</span>
28+
);
29+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//// [file.tsx]
2+
import React = require('react');
3+
4+
interface ComponentProps {
5+
property1: string;
6+
property2: number;
7+
}
8+
9+
export default function Component(props: ComponentProps) {
10+
return (
11+
// Error extra property
12+
<AnotherComponent {...props} Property1/>
13+
);
14+
}
15+
16+
interface AnotherComponentProps {
17+
property1: string;
18+
}
19+
20+
function AnotherComponent({ property1 }: AnotherComponentProps) {
21+
return (
22+
<span>{property1}</span>
23+
);
24+
}
25+
26+
//// [file.jsx]
27+
"use strict";
28+
exports.__esModule = true;
29+
var React = require("react");
30+
function Component(props) {
31+
return (
32+
// Error extra property
33+
<AnotherComponent {...props} Property1/>);
34+
}
35+
exports["default"] = Component;
36+
function AnotherComponent(_a) {
37+
var property1 = _a.property1;
38+
return (<span>{property1}</span>);
39+
}

0 commit comments

Comments
 (0)