Skip to content

Commit 5f8a1b5

Browse files
Add baselines
1 parent 269d37a commit 5f8a1b5

15 files changed

Lines changed: 761 additions & 1 deletion
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
tests/cases/conformance/jsx/file.tsx(42,27): error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'IntrinsicAttributes & SingleChildProp'.
2+
Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'SingleChildProp'.
3+
Types of property 'children' are incompatible.
4+
Type 'Element[]' is not assignable to type 'Element'.
5+
Property 'type' is missing in type 'Element[]'.
6+
7+
8+
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
9+
import React = require('react');
10+
11+
interface Prop {
12+
a: number,
13+
b: string,
14+
children: JSX.Element | JSX.Element[];
15+
}
16+
17+
class Button extends React.Component<any, any> {
18+
render() {
19+
return (<div>My Button</div>)
20+
}
21+
}
22+
23+
function AnotherButton(p: any) {
24+
return <h1>Just Another Button</h1>;
25+
}
26+
27+
function Comp(p: Prop) {
28+
return <div>{p.b}</div>;
29+
}
30+
31+
// OK
32+
let k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>;
33+
let k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>;
34+
let k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>;
35+
36+
interface SingleChildProp {
37+
a: number,
38+
b: string,
39+
children: JSX.Element;
40+
}
41+
42+
function SingleChildComp(p: SingleChildProp) {
43+
return <div>{p.b}</div>;
44+
}
45+
46+
// OK
47+
let k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>;
48+
49+
// Error
50+
let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
51+
~~~~~~~~~~~~~
52+
!!! error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'IntrinsicAttributes & SingleChildProp'.
53+
!!! error TS2322: Type '{ a: 10; b: "hi"; children: Element[]; }' is not assignable to type 'SingleChildProp'.
54+
!!! error TS2322: Types of property 'children' are incompatible.
55+
!!! error TS2322: Type 'Element[]' is not assignable to type 'Element'.
56+
!!! error TS2322: Property 'type' is missing in type 'Element[]'.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//// [file.tsx]
2+
import React = require('react');
3+
4+
interface Prop {
5+
a: number,
6+
b: string,
7+
children: JSX.Element | JSX.Element[];
8+
}
9+
10+
class Button extends React.Component<any, any> {
11+
render() {
12+
return (<div>My Button</div>)
13+
}
14+
}
15+
16+
function AnotherButton(p: any) {
17+
return <h1>Just Another Button</h1>;
18+
}
19+
20+
function Comp(p: Prop) {
21+
return <div>{p.b}</div>;
22+
}
23+
24+
// OK
25+
let k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>;
26+
let k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>;
27+
let k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>;
28+
29+
interface SingleChildProp {
30+
a: number,
31+
b: string,
32+
children: JSX.Element;
33+
}
34+
35+
function SingleChildComp(p: SingleChildProp) {
36+
return <div>{p.b}</div>;
37+
}
38+
39+
// OK
40+
let k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>;
41+
42+
// Error
43+
let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
44+
45+
//// [file.jsx]
46+
"use strict";
47+
var __extends = (this && this.__extends) || (function () {
48+
var extendStatics = Object.setPrototypeOf ||
49+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
50+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
51+
return function (d, b) {
52+
extendStatics(d, b);
53+
function __() { this.constructor = d; }
54+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
55+
};
56+
})();
57+
exports.__esModule = true;
58+
var React = require("react");
59+
var Button = /** @class */ (function (_super) {
60+
__extends(Button, _super);
61+
function Button() {
62+
return _super !== null && _super.apply(this, arguments) || this;
63+
}
64+
Button.prototype.render = function () {
65+
return (<div>My Button</div>);
66+
};
67+
return Button;
68+
}(React.Component));
69+
function AnotherButton(p) {
70+
return <h1>Just Another Button</h1>;
71+
}
72+
function Comp(p) {
73+
return <div>{p.b}</div>;
74+
}
75+
// OK
76+
var k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>;
77+
var k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>;
78+
var k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>;
79+
function SingleChildComp(p) {
80+
return <div>{p.b}</div>;
81+
}
82+
// OK
83+
var k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>;
84+
// Error
85+
var k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
=== tests/cases/conformance/jsx/file.tsx ===
2+
import React = require('react');
3+
>React : Symbol(React, Decl(file.tsx, 0, 0))
4+
5+
interface Prop {
6+
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
7+
8+
a: number,
9+
>a : Symbol(Prop.a, Decl(file.tsx, 2, 16))
10+
11+
b: string,
12+
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
13+
14+
children: JSX.Element | JSX.Element[];
15+
>children : Symbol(Prop.children, Decl(file.tsx, 4, 14))
16+
>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1))
17+
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27))
18+
>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1))
19+
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27))
20+
}
21+
22+
class Button extends React.Component<any, any> {
23+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
24+
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66))
25+
>React : Symbol(React, Decl(file.tsx, 0, 0))
26+
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66))
27+
28+
render() {
29+
>render : Symbol(Button.render, Decl(file.tsx, 8, 48))
30+
31+
return (<div>My Button</div>)
32+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
33+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
34+
}
35+
}
36+
37+
function AnotherButton(p: any) {
38+
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
39+
>p : Symbol(p, Decl(file.tsx, 14, 23))
40+
41+
return <h1>Just Another Button</h1>;
42+
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47))
43+
>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47))
44+
}
45+
46+
function Comp(p: Prop) {
47+
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
48+
>p : Symbol(p, Decl(file.tsx, 18, 14))
49+
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32))
50+
51+
return <div>{p.b}</div>;
52+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
53+
>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
54+
>p : Symbol(p, Decl(file.tsx, 18, 14))
55+
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14))
56+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
57+
}
58+
59+
// OK
60+
let k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>;
61+
>k1 : Symbol(k1, Decl(file.tsx, 23, 3))
62+
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
63+
>a : Symbol(a, Decl(file.tsx, 23, 14))
64+
>b : Symbol(b, Decl(file.tsx, 23, 21))
65+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
66+
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
67+
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
68+
69+
let k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>;
70+
>k2 : Symbol(k2, Decl(file.tsx, 24, 3))
71+
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
72+
>a : Symbol(a, Decl(file.tsx, 24, 14))
73+
>b : Symbol(b, Decl(file.tsx, 24, 21))
74+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
75+
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
76+
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
77+
78+
let k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>;
79+
>k3 : Symbol(k3, Decl(file.tsx, 25, 3))
80+
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
81+
>a : Symbol(a, Decl(file.tsx, 25, 14))
82+
>b : Symbol(b, Decl(file.tsx, 25, 21))
83+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
84+
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
85+
>Comp : Symbol(Comp, Decl(file.tsx, 16, 1))
86+
87+
interface SingleChildProp {
88+
>SingleChildProp : Symbol(SingleChildProp, Decl(file.tsx, 25, 69))
89+
90+
a: number,
91+
>a : Symbol(SingleChildProp.a, Decl(file.tsx, 27, 27))
92+
93+
b: string,
94+
>b : Symbol(SingleChildProp.b, Decl(file.tsx, 28, 14))
95+
96+
children: JSX.Element;
97+
>children : Symbol(SingleChildProp.children, Decl(file.tsx, 29, 14))
98+
>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1))
99+
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27))
100+
}
101+
102+
function SingleChildComp(p: SingleChildProp) {
103+
>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1))
104+
>p : Symbol(p, Decl(file.tsx, 33, 25))
105+
>SingleChildProp : Symbol(SingleChildProp, Decl(file.tsx, 25, 69))
106+
107+
return <div>{p.b}</div>;
108+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
109+
>p.b : Symbol(SingleChildProp.b, Decl(file.tsx, 28, 14))
110+
>p : Symbol(p, Decl(file.tsx, 33, 25))
111+
>b : Symbol(SingleChildProp.b, Decl(file.tsx, 28, 14))
112+
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45))
113+
}
114+
115+
// OK
116+
let k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>;
117+
>k4 : Symbol(k4, Decl(file.tsx, 38, 3))
118+
>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1))
119+
>a : Symbol(a, Decl(file.tsx, 38, 25))
120+
>b : Symbol(b, Decl(file.tsx, 38, 32))
121+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
122+
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
123+
>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1))
124+
125+
// Error
126+
let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
127+
>k5 : Symbol(k5, Decl(file.tsx, 41, 3))
128+
>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1))
129+
>a : Symbol(a, Decl(file.tsx, 41, 25))
130+
>b : Symbol(b, Decl(file.tsx, 41, 32))
131+
>Button : Symbol(Button, Decl(file.tsx, 6, 1))
132+
>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1))
133+
>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1))
134+

0 commit comments

Comments
 (0)