Add more tests and update baselines

This commit is contained in:
Yui T 2017-05-11 22:40:34 -07:00 committed by Mohamed Hegazy
parent 5eb9fd04c1
commit dbae5d210e
16 changed files with 472 additions and 3 deletions

View File

@ -0,0 +1,20 @@
tests/cases/conformance/jsx/file.tsx(12,36): error TS2339: Property 'x' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<B1<{}>> & { children?: ReactNode; }'.
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
import React = require('react');
class B1<T extends { x: string }> extends React.Component<T, {}> {
render() {
return <div>hi</div>;
}
}
class B<U> extends React.Component<U, {}> {
props: U;
render() {
// Should be an ok but as of 2.3.3 this will be an error as we will instantiate B1.props to be empty object
return <B1 {...this.props} x="hi" />;
~~~~~~
!!! error TS2339: Property 'x' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<B1<{}>> & { children?: ReactNode; }'.
}
}

View File

@ -0,0 +1,51 @@
//// [file.tsx]
import React = require('react');
class B1<T extends { x: string }> extends React.Component<T, {}> {
render() {
return <div>hi</div>;
}
}
class B<U> extends React.Component<U, {}> {
props: U;
render() {
// Should be an ok but as of 2.3.3 this will be an error as we will instantiate B1.props to be empty object
return <B1 {...this.props} x="hi" />;
}
}
//// [file.jsx]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
var React = require("react");
var B1 = (function (_super) {
__extends(B1, _super);
function B1() {
return _super !== null && _super.apply(this, arguments) || this;
}
B1.prototype.render = function () {
return <div>hi</div>;
};
return B1;
}(React.Component));
var B = (function (_super) {
__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
B.prototype.render = function () {
// Should be an ok but as of 2.3.3 this will be an error as we will instantiate B1.props to be empty object
return <B1 {...this.props} x="hi"/>;
};
return B;
}(React.Component));

View File

@ -0,0 +1,49 @@
//// [file.tsx]
import React = require('react');
class B1<T extends { x: string } = { x:string } > extends React.Component<T, {}> {
render() {
return <div>hi</div>;
}
}
class B<U> extends React.Component<U, {}> {
props: U;
render() {
return <B1 {...this.props} x="hi" />;
}
}
//// [file.jsx]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
var React = require("react");
var B1 = (function (_super) {
__extends(B1, _super);
function B1() {
return _super !== null && _super.apply(this, arguments) || this;
}
B1.prototype.render = function () {
return <div>hi</div>;
};
return B1;
}(React.Component));
var B = (function (_super) {
__extends(B, _super);
function B() {
return _super !== null && _super.apply(this, arguments) || this;
}
B.prototype.render = function () {
return <B1 {...this.props} x="hi"/>;
};
return B;
}(React.Component));

View File

@ -0,0 +1,45 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
class B1<T extends { x: string } = { x:string } > extends React.Component<T, {}> {
>B1 : Symbol(B1, Decl(file.tsx, 0, 32))
>T : Symbol(T, Decl(file.tsx, 2, 9))
>x : Symbol(x, Decl(file.tsx, 2, 20))
>x : Symbol(x, Decl(file.tsx, 2, 36))
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>React : Symbol(React, Decl(file.tsx, 0, 0))
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>T : Symbol(T, Decl(file.tsx, 2, 9))
render() {
>render : Symbol(B1.render, Decl(file.tsx, 2, 82))
return <div>hi</div>;
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45))
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45))
}
}
class B<U> extends React.Component<U, {}> {
>B : Symbol(B, Decl(file.tsx, 6, 1))
>U : Symbol(U, Decl(file.tsx, 7, 8))
>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>React : Symbol(React, Decl(file.tsx, 0, 0))
>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55))
>U : Symbol(U, Decl(file.tsx, 7, 8))
props: U;
>props : Symbol(B.props, Decl(file.tsx, 7, 43))
>U : Symbol(U, Decl(file.tsx, 7, 8))
render() {
>render : Symbol(B.render, Decl(file.tsx, 8, 13))
return <B1 {...this.props} x="hi" />;
>B1 : Symbol(B1, Decl(file.tsx, 0, 32))
>this.props : Symbol(B.props, Decl(file.tsx, 7, 43))
>this : Symbol(B, Decl(file.tsx, 6, 1))
>props : Symbol(B.props, Decl(file.tsx, 7, 43))
>x : Symbol(x, Decl(file.tsx, 10, 34))
}
}

View File

@ -0,0 +1,47 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
class B1<T extends { x: string } = { x:string } > extends React.Component<T, {}> {
>B1 : B1<T>
>T : T
>x : string
>x : string
>React.Component : React.Component<T, {}>
>React : typeof React
>Component : typeof React.Component
>T : T
render() {
>render : () => JSX.Element
return <div>hi</div>;
><div>hi</div> : JSX.Element
>div : any
>div : any
}
}
class B<U> extends React.Component<U, {}> {
>B : B<U>
>U : U
>React.Component : React.Component<U, {}>
>React : typeof React
>Component : typeof React.Component
>U : U
props: U;
>props : U
>U : U
render() {
>render : () => JSX.Element
return <B1 {...this.props} x="hi" />;
><B1 {...this.props} x="hi" /> : JSX.Element
>B1 : typeof B1
>this.props : U
>this : this
>props : U
>x : string
}
}

View File

@ -0,0 +1,22 @@
//// [file.tsx]
import React = require('react');
declare function Component<T>(props: T) : JSX.Element;
const decorator = function <U>(props: U) {
return <Component {...props} />;
}
const decorator1 = function <U extends {x: string}>(props: U) {
return <Component {...props} x="hi"/>;
}
//// [file.jsx]
"use strict";
exports.__esModule = true;
var React = require("react");
var decorator = function (props) {
return <Component {...props}/>;
};
var decorator1 = function (props) {
return <Component {...props} x="hi"/>;
};

View File

@ -0,0 +1,35 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
declare function Component<T>(props: T) : JSX.Element;
>Component : Symbol(Component, Decl(file.tsx, 0, 32))
>T : Symbol(T, Decl(file.tsx, 2, 27))
>props : Symbol(props, Decl(file.tsx, 2, 30))
>T : Symbol(T, Decl(file.tsx, 2, 27))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
const decorator = function <U>(props: U) {
>decorator : Symbol(decorator, Decl(file.tsx, 3, 5))
>U : Symbol(U, Decl(file.tsx, 3, 28))
>props : Symbol(props, Decl(file.tsx, 3, 31))
>U : Symbol(U, Decl(file.tsx, 3, 28))
return <Component {...props} />;
>Component : Symbol(Component, Decl(file.tsx, 0, 32))
>props : Symbol(props, Decl(file.tsx, 3, 31))
}
const decorator1 = function <U extends {x: string}>(props: U) {
>decorator1 : Symbol(decorator1, Decl(file.tsx, 7, 5))
>U : Symbol(U, Decl(file.tsx, 7, 29))
>x : Symbol(x, Decl(file.tsx, 7, 40))
>props : Symbol(props, Decl(file.tsx, 7, 52))
>U : Symbol(U, Decl(file.tsx, 7, 29))
return <Component {...props} x="hi"/>;
>Component : Symbol(Component, Decl(file.tsx, 0, 32))
>props : Symbol(props, Decl(file.tsx, 7, 52))
>x : Symbol(x, Decl(file.tsx, 8, 32))
}

View File

@ -0,0 +1,39 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
declare function Component<T>(props: T) : JSX.Element;
>Component : <T>(props: T) => JSX.Element
>T : T
>props : T
>T : T
>JSX : any
>Element : JSX.Element
const decorator = function <U>(props: U) {
>decorator : <U>(props: U) => JSX.Element
>function <U>(props: U) { return <Component {...props} />;} : <U>(props: U) => JSX.Element
>U : U
>props : U
>U : U
return <Component {...props} />;
><Component {...props} /> : JSX.Element
>Component : <T>(props: T) => JSX.Element
>props : U
}
const decorator1 = function <U extends {x: string}>(props: U) {
>decorator1 : <U extends { x: string; }>(props: U) => JSX.Element
>function <U extends {x: string}>(props: U) { return <Component {...props} x="hi"/>;} : <U extends { x: string; }>(props: U) => JSX.Element
>U : U
>x : string
>props : U
>U : U
return <Component {...props} x="hi"/>;
><Component {...props} x="hi"/> : JSX.Element
>Component : <T>(props: T) => JSX.Element
>props : U
>x : string
}

View File

@ -0,0 +1,22 @@
//// [file.tsx]
import React = require('react');
declare function Component<T>(props: T) : JSX.Element;
const decorator = function <U>(props: U) {
return <Component {...props} />;
}
const decorator1 = function <U extends {x: string}>(props: U) {
return <Component {...props} />;
}
//// [file.jsx]
"use strict";
exports.__esModule = true;
var React = require("react");
var decorator = function (props) {
return <Component {...props}/>;
};
var decorator1 = function (props) {
return <Component {...props}/>;
};

View File

@ -0,0 +1,34 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : Symbol(React, Decl(file.tsx, 0, 0))
declare function Component<T>(props: T) : JSX.Element;
>Component : Symbol(Component, Decl(file.tsx, 0, 32))
>T : Symbol(T, Decl(file.tsx, 2, 27))
>props : Symbol(props, Decl(file.tsx, 2, 30))
>T : Symbol(T, Decl(file.tsx, 2, 27))
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1))
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27))
const decorator = function <U>(props: U) {
>decorator : Symbol(decorator, Decl(file.tsx, 3, 5))
>U : Symbol(U, Decl(file.tsx, 3, 28))
>props : Symbol(props, Decl(file.tsx, 3, 31))
>U : Symbol(U, Decl(file.tsx, 3, 28))
return <Component {...props} />;
>Component : Symbol(Component, Decl(file.tsx, 0, 32))
>props : Symbol(props, Decl(file.tsx, 3, 31))
}
const decorator1 = function <U extends {x: string}>(props: U) {
>decorator1 : Symbol(decorator1, Decl(file.tsx, 7, 5))
>U : Symbol(U, Decl(file.tsx, 7, 29))
>x : Symbol(x, Decl(file.tsx, 7, 40))
>props : Symbol(props, Decl(file.tsx, 7, 52))
>U : Symbol(U, Decl(file.tsx, 7, 29))
return <Component {...props} />;
>Component : Symbol(Component, Decl(file.tsx, 0, 32))
>props : Symbol(props, Decl(file.tsx, 7, 52))
}

View File

@ -0,0 +1,38 @@
=== tests/cases/conformance/jsx/file.tsx ===
import React = require('react');
>React : typeof React
declare function Component<T>(props: T) : JSX.Element;
>Component : <T>(props: T) => JSX.Element
>T : T
>props : T
>T : T
>JSX : any
>Element : JSX.Element
const decorator = function <U>(props: U) {
>decorator : <U>(props: U) => JSX.Element
>function <U>(props: U) { return <Component {...props} />;} : <U>(props: U) => JSX.Element
>U : U
>props : U
>U : U
return <Component {...props} />;
><Component {...props} /> : JSX.Element
>Component : <T>(props: T) => JSX.Element
>props : U
}
const decorator1 = function <U extends {x: string}>(props: U) {
>decorator1 : <U extends { x: string; }>(props: U) => JSX.Element
>function <U extends {x: string}>(props: U) { return <Component {...props} />;} : <U extends { x: string; }>(props: U) => JSX.Element
>U : U
>x : string
>props : U
>U : U
return <Component {...props} />;
><Component {...props} /> : JSX.Element
>Component : <T>(props: T) => JSX.Element
>props : U
}

View File

@ -21,8 +21,8 @@ var MainMenu: React.StatelessComponent<{}> = (props) => (<div>
>MainMenu : React.StatelessComponent<{}>
>React : any
>StatelessComponent : React.StatelessComponent<P>
>(props) => (<div> <h3>Main Menu</h3></div>) : (props: {}) => JSX.Element
>props : {}
>(props) => (<div> <h3>Main Menu</h3></div>) : (props: { children?: React.ReactNode; }) => JSX.Element
>props : { children?: React.ReactNode; }
>(<div> <h3>Main Menu</h3></div>) : JSX.Element
><div> <h3>Main Menu</h3></div> : JSX.Element
>div : any
@ -40,7 +40,7 @@ var App: React.StatelessComponent<{ children }> = ({children}) => (
>React : any
>StatelessComponent : React.StatelessComponent<P>
>children : any
>({children}) => ( <div > <MainMenu/> </div>) : ({children}: { children: any; }) => JSX.Element
>({children}) => ( <div > <MainMenu/> </div>) : ({children}: { children: any; } & { children?: React.ReactNode; }) => JSX.Element
>children : any
>( <div > <MainMenu/> </div>) : JSX.Element

View File

@ -0,0 +1,19 @@
// @filename: file.tsx
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
import React = require('react');
class B1<T extends { x: string }> extends React.Component<T, {}> {
render() {
return <div>hi</div>;
}
}
class B<U> extends React.Component<U, {}> {
props: U;
render() {
// Should be an ok but as of 2.3.3 this will be an error as we will instantiate B1.props to be empty object
return <B1 {...this.props} x="hi" />;
}
}

View File

@ -0,0 +1,18 @@
// @filename: file.tsx
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
import React = require('react');
class B1<T extends { x: string } = { x:string } > extends React.Component<T, {}> {
render() {
return <div>hi</div>;
}
}
class B<U> extends React.Component<U, {}> {
props: U;
render() {
return <B1 {...this.props} x="hi" />;
}
}

View File

@ -0,0 +1,15 @@
// @filename: file.tsx
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
import React = require('react');
declare function Component<T>(props: T) : JSX.Element;
const decorator = function <U>(props: U) {
return <Component {...props} />;
}
const decorator1 = function <U extends {x: string}>(props: U) {
return <Component {...props} x="hi"/>;
}

View File

@ -0,0 +1,15 @@
// @filename: file.tsx
// @jsx: preserve
// @noLib: true
// @libFiles: react.d.ts,lib.d.ts
import React = require('react');
declare function Component<T>(props: T) : JSX.Element;
const decorator = function <U>(props: U) {
return <Component {...props} />;
}
const decorator1 = function <U extends {x: string}>(props: U) {
return <Component {...props} />;
}