mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-04 14:56:16 -05:00
Updates tests and baselines
This commit is contained in:
@@ -9,7 +9,15 @@ interface ButtonProp {
|
||||
|
||||
class Button extends React.Component<ButtonProp, any> {
|
||||
render() {
|
||||
return <InnerButton {...this.props} />
|
||||
let condition: boolean;
|
||||
if (condition) {
|
||||
return <InnerButton {...this.props} />
|
||||
}
|
||||
else {
|
||||
return (<InnerButton {...this.props} >
|
||||
<div>Hello World</div>
|
||||
</InnerButton>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +52,15 @@ var Button = (function (_super) {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Button.prototype.render = function () {
|
||||
return <InnerButton {...this.props}/>;
|
||||
var condition;
|
||||
if (condition) {
|
||||
return <InnerButton {...this.props}/>;
|
||||
}
|
||||
else {
|
||||
return (<InnerButton {...this.props}>
|
||||
<div>Hello World</div>
|
||||
</InnerButton>);
|
||||
}
|
||||
};
|
||||
return Button;
|
||||
}(React.Component));
|
||||
|
||||
@@ -26,30 +26,51 @@ class Button extends React.Component<ButtonProp, any> {
|
||||
render() {
|
||||
>render : Symbol(Button.render, Decl(file.tsx, 8, 55))
|
||||
|
||||
return <InnerButton {...this.props} />
|
||||
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 16, 1))
|
||||
let condition: boolean;
|
||||
>condition : Symbol(condition, Decl(file.tsx, 10, 5))
|
||||
|
||||
if (condition) {
|
||||
>condition : Symbol(condition, Decl(file.tsx, 10, 5))
|
||||
|
||||
return <InnerButton {...this.props} />
|
||||
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
|
||||
>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
|
||||
>this : Symbol(Button, Decl(file.tsx, 6, 1))
|
||||
>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
|
||||
}
|
||||
else {
|
||||
return (<InnerButton {...this.props} >
|
||||
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
|
||||
>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
|
||||
>this : Symbol(Button, Decl(file.tsx, 6, 1))
|
||||
>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37))
|
||||
|
||||
<div>Hello World</div>
|
||||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45))
|
||||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45))
|
||||
|
||||
</InnerButton>);
|
||||
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface InnerButtonProp {
|
||||
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 12, 1))
|
||||
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 20, 1))
|
||||
|
||||
a: number
|
||||
>a : Symbol(InnerButtonProp.a, Decl(file.tsx, 14, 27))
|
||||
>a : Symbol(InnerButtonProp.a, Decl(file.tsx, 22, 27))
|
||||
}
|
||||
|
||||
class InnerButton extends React.Component<InnerButtonProp, any> {
|
||||
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 16, 1))
|
||||
>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1))
|
||||
>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))
|
||||
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 12, 1))
|
||||
>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 20, 1))
|
||||
|
||||
render() {
|
||||
>render : Symbol(InnerButton.render, Decl(file.tsx, 18, 65))
|
||||
>render : Symbol(InnerButton.render, Decl(file.tsx, 26, 65))
|
||||
|
||||
return (<button>Hello</button>);
|
||||
>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43))
|
||||
|
||||
@@ -26,12 +26,36 @@ class Button extends React.Component<ButtonProp, any> {
|
||||
render() {
|
||||
>render : () => JSX.Element
|
||||
|
||||
return <InnerButton {...this.props} />
|
||||
let condition: boolean;
|
||||
>condition : boolean
|
||||
|
||||
if (condition) {
|
||||
>condition : boolean
|
||||
|
||||
return <InnerButton {...this.props} />
|
||||
><InnerButton {...this.props} /> : JSX.Element
|
||||
>InnerButton : typeof InnerButton
|
||||
>this.props : ButtonProp & { children?: React.ReactNode; }
|
||||
>this : this
|
||||
>props : ButtonProp & { children?: React.ReactNode; }
|
||||
}
|
||||
else {
|
||||
return (<InnerButton {...this.props} >
|
||||
>(<InnerButton {...this.props} > <div>Hello World</div> </InnerButton>) : JSX.Element
|
||||
><InnerButton {...this.props} > <div>Hello World</div> </InnerButton> : JSX.Element
|
||||
>InnerButton : typeof InnerButton
|
||||
>this.props : ButtonProp & { children?: React.ReactNode; }
|
||||
>this : this
|
||||
>props : ButtonProp & { children?: React.ReactNode; }
|
||||
|
||||
<div>Hello World</div>
|
||||
><div>Hello World</div> : JSX.Element
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
</InnerButton>);
|
||||
>InnerButton : typeof InnerButton
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
tests/cases/conformance/jsx/file.tsx(12,30): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
interface ButtonProp {
|
||||
a: number,
|
||||
b: string,
|
||||
children: Button;
|
||||
}
|
||||
|
||||
class Button extends React.Component<ButtonProp, any> {
|
||||
render() {
|
||||
// Error children are specified twice
|
||||
return (<InnerButton {...this.props} children="hi">
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
|
||||
<div>Hello World</div>
|
||||
</InnerButton>);
|
||||
}
|
||||
}
|
||||
|
||||
interface InnerButtonProp {
|
||||
a: number
|
||||
}
|
||||
|
||||
class InnerButton extends React.Component<InnerButtonProp, any> {
|
||||
render() {
|
||||
return (<button>Hello</button>);
|
||||
}
|
||||
}
|
||||
|
||||
66
tests/baselines/reference/checkJsxChildrenProperty13.js
Normal file
66
tests/baselines/reference/checkJsxChildrenProperty13.js
Normal file
@@ -0,0 +1,66 @@
|
||||
//// [file.tsx]
|
||||
import React = require('react');
|
||||
|
||||
interface ButtonProp {
|
||||
a: number,
|
||||
b: string,
|
||||
children: Button;
|
||||
}
|
||||
|
||||
class Button extends React.Component<ButtonProp, any> {
|
||||
render() {
|
||||
// Error children are specified twice
|
||||
return (<InnerButton {...this.props} children="hi">
|
||||
<div>Hello World</div>
|
||||
</InnerButton>);
|
||||
}
|
||||
}
|
||||
|
||||
interface InnerButtonProp {
|
||||
a: number
|
||||
}
|
||||
|
||||
class InnerButton extends React.Component<InnerButtonProp, any> {
|
||||
render() {
|
||||
return (<button>Hello</button>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [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 Button = (function (_super) {
|
||||
__extends(Button, _super);
|
||||
function Button() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Button.prototype.render = function () {
|
||||
// Error children are specified twice
|
||||
return (<InnerButton {...this.props} children="hi">
|
||||
<div>Hello World</div>
|
||||
</InnerButton>);
|
||||
};
|
||||
return Button;
|
||||
}(React.Component));
|
||||
var InnerButton = (function (_super) {
|
||||
__extends(InnerButton, _super);
|
||||
function InnerButton() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
InnerButton.prototype.render = function () {
|
||||
return (<button>Hello</button>);
|
||||
};
|
||||
return InnerButton;
|
||||
}(React.Component));
|
||||
@@ -7,16 +7,22 @@ interface ComponentProps {
|
||||
}
|
||||
|
||||
export default function Component(props: ComponentProps) {
|
||||
return (
|
||||
<AnotherComponent {...props} />
|
||||
);
|
||||
let condition1: boolean;
|
||||
if (condition1) {
|
||||
return (
|
||||
<ChildComponent {...props} />
|
||||
);
|
||||
}
|
||||
else {
|
||||
return (<ChildComponent {...props} property1="NewString" />);
|
||||
}
|
||||
}
|
||||
|
||||
interface AnotherComponentProps {
|
||||
property1: string;
|
||||
}
|
||||
|
||||
function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
function ChildComponent({ property1 }: AnotherComponentProps) {
|
||||
return (
|
||||
<span>{property1}</span>
|
||||
);
|
||||
@@ -27,10 +33,16 @@ function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
exports.__esModule = true;
|
||||
var React = require("react");
|
||||
function Component(props) {
|
||||
return (<AnotherComponent {...props}/>);
|
||||
var condition1;
|
||||
if (condition1) {
|
||||
return (<ChildComponent {...props}/>);
|
||||
}
|
||||
else {
|
||||
return (<ChildComponent {...props} property1="NewString"/>);
|
||||
}
|
||||
}
|
||||
exports["default"] = Component;
|
||||
function AnotherComponent(_a) {
|
||||
function ChildComponent(_a) {
|
||||
var property1 = _a.property1;
|
||||
return (<span>{property1}</span>);
|
||||
}
|
||||
|
||||
@@ -17,30 +17,43 @@ export default function Component(props: ComponentProps) {
|
||||
>props : Symbol(props, Decl(file.tsx, 7, 34))
|
||||
>ComponentProps : Symbol(ComponentProps, Decl(file.tsx, 0, 32))
|
||||
|
||||
return (
|
||||
<AnotherComponent {...props} />
|
||||
>AnotherComponent : Symbol(AnotherComponent, Decl(file.tsx, 15, 1))
|
||||
let condition1: boolean;
|
||||
>condition1 : Symbol(condition1, Decl(file.tsx, 8, 7))
|
||||
|
||||
if (condition1) {
|
||||
>condition1 : Symbol(condition1, Decl(file.tsx, 8, 7))
|
||||
|
||||
return (
|
||||
<ChildComponent {...props} />
|
||||
>ChildComponent : Symbol(ChildComponent, Decl(file.tsx, 21, 1))
|
||||
>props : Symbol(props, Decl(file.tsx, 7, 34))
|
||||
|
||||
);
|
||||
);
|
||||
}
|
||||
else {
|
||||
return (<ChildComponent {...props} property1="NewString" />);
|
||||
>ChildComponent : Symbol(ChildComponent, Decl(file.tsx, 21, 1))
|
||||
>props : Symbol(props, Decl(file.tsx, 7, 34))
|
||||
>property1 : Symbol(property1, Decl(file.tsx, 15, 42))
|
||||
}
|
||||
}
|
||||
|
||||
interface AnotherComponentProps {
|
||||
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 11, 1))
|
||||
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 17, 1))
|
||||
|
||||
property1: string;
|
||||
>property1 : Symbol(AnotherComponentProps.property1, Decl(file.tsx, 13, 33))
|
||||
>property1 : Symbol(AnotherComponentProps.property1, Decl(file.tsx, 19, 33))
|
||||
}
|
||||
|
||||
function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
>AnotherComponent : Symbol(AnotherComponent, Decl(file.tsx, 15, 1))
|
||||
>property1 : Symbol(property1, Decl(file.tsx, 17, 27))
|
||||
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 11, 1))
|
||||
function ChildComponent({ property1 }: AnotherComponentProps) {
|
||||
>ChildComponent : Symbol(ChildComponent, Decl(file.tsx, 21, 1))
|
||||
>property1 : Symbol(property1, Decl(file.tsx, 23, 25))
|
||||
>AnotherComponentProps : Symbol(AnotherComponentProps, Decl(file.tsx, 17, 1))
|
||||
|
||||
return (
|
||||
<span>{property1}</span>
|
||||
>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2460, 51))
|
||||
>property1 : Symbol(property1, Decl(file.tsx, 17, 27))
|
||||
>property1 : Symbol(property1, Decl(file.tsx, 23, 25))
|
||||
>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2460, 51))
|
||||
|
||||
);
|
||||
|
||||
@@ -17,15 +17,30 @@ export default function Component(props: ComponentProps) {
|
||||
>props : ComponentProps
|
||||
>ComponentProps : ComponentProps
|
||||
|
||||
return (
|
||||
>( <AnotherComponent {...props} /> ) : JSX.Element
|
||||
let condition1: boolean;
|
||||
>condition1 : boolean
|
||||
|
||||
<AnotherComponent {...props} />
|
||||
><AnotherComponent {...props} /> : JSX.Element
|
||||
>AnotherComponent : ({property1}: AnotherComponentProps) => JSX.Element
|
||||
if (condition1) {
|
||||
>condition1 : boolean
|
||||
|
||||
return (
|
||||
>( <ChildComponent {...props} /> ) : JSX.Element
|
||||
|
||||
<ChildComponent {...props} />
|
||||
><ChildComponent {...props} /> : JSX.Element
|
||||
>ChildComponent : ({property1}: AnotherComponentProps) => JSX.Element
|
||||
>props : ComponentProps
|
||||
|
||||
);
|
||||
);
|
||||
}
|
||||
else {
|
||||
return (<ChildComponent {...props} property1="NewString" />);
|
||||
>(<ChildComponent {...props} property1="NewString" />) : JSX.Element
|
||||
><ChildComponent {...props} property1="NewString" /> : JSX.Element
|
||||
>ChildComponent : ({property1}: AnotherComponentProps) => JSX.Element
|
||||
>props : ComponentProps
|
||||
>property1 : string
|
||||
}
|
||||
}
|
||||
|
||||
interface AnotherComponentProps {
|
||||
@@ -35,8 +50,8 @@ interface AnotherComponentProps {
|
||||
>property1 : string
|
||||
}
|
||||
|
||||
function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
>AnotherComponent : ({property1}: AnotherComponentProps) => JSX.Element
|
||||
function ChildComponent({ property1 }: AnotherComponentProps) {
|
||||
>ChildComponent : ({property1}: AnotherComponentProps) => JSX.Element
|
||||
>property1 : string
|
||||
>AnotherComponentProps : AnotherComponentProps
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
tests/cases/conformance/jsx/file.tsx(11,27): error TS2322: Type '{ property1: string; property2: number; }' is not assignable to type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
Type '{ property1: string; property2: number; }' is not assignable to type 'AnotherComponentProps'.
|
||||
Property 'AnotherProperty1' is missing in type '{ property1: string; property2: number; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
interface ComponentProps {
|
||||
property1: string;
|
||||
property2: number;
|
||||
}
|
||||
|
||||
export default function Component(props: ComponentProps) {
|
||||
return (
|
||||
// Error: missing property
|
||||
<AnotherComponent {...props} />
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ property1: string; property2: number; }' is not assignable to type 'IntrinsicAttributes & AnotherComponentProps'.
|
||||
!!! error TS2322: Type '{ property1: string; property2: number; }' is not assignable to type 'AnotherComponentProps'.
|
||||
!!! error TS2322: Property 'AnotherProperty1' is missing in type '{ property1: string; property2: number; }'.
|
||||
);
|
||||
}
|
||||
|
||||
interface AnotherComponentProps {
|
||||
property1: string;
|
||||
AnotherProperty1: string;
|
||||
property2: boolean;
|
||||
}
|
||||
|
||||
function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
return (
|
||||
<span>{property1}</span>
|
||||
);
|
||||
}
|
||||
41
tests/baselines/reference/tsxSpreadAttributesResolution16.js
Normal file
41
tests/baselines/reference/tsxSpreadAttributesResolution16.js
Normal file
@@ -0,0 +1,41 @@
|
||||
//// [file.tsx]
|
||||
import React = require('react');
|
||||
|
||||
interface ComponentProps {
|
||||
property1: string;
|
||||
property2: number;
|
||||
}
|
||||
|
||||
export default function Component(props: ComponentProps) {
|
||||
return (
|
||||
// Error: missing property
|
||||
<AnotherComponent {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
interface AnotherComponentProps {
|
||||
property1: string;
|
||||
AnotherProperty1: string;
|
||||
property2: boolean;
|
||||
}
|
||||
|
||||
function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
return (
|
||||
<span>{property1}</span>
|
||||
);
|
||||
}
|
||||
|
||||
//// [file.jsx]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var React = require("react");
|
||||
function Component(props) {
|
||||
return (
|
||||
// Error: missing property
|
||||
<AnotherComponent {...props}/>);
|
||||
}
|
||||
exports["default"] = Component;
|
||||
function AnotherComponent(_a) {
|
||||
var property1 = _a.property1;
|
||||
return (<span>{property1}</span>);
|
||||
}
|
||||
@@ -13,7 +13,15 @@ interface ButtonProp {
|
||||
|
||||
class Button extends React.Component<ButtonProp, any> {
|
||||
render() {
|
||||
return <InnerButton {...this.props} />
|
||||
let condition: boolean;
|
||||
if (condition) {
|
||||
return <InnerButton {...this.props} />
|
||||
}
|
||||
else {
|
||||
return (<InnerButton {...this.props} >
|
||||
<div>Hello World</div>
|
||||
</InnerButton>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
31
tests/cases/conformance/jsx/checkJsxChildrenProperty13.tsx
Normal file
31
tests/cases/conformance/jsx/checkJsxChildrenProperty13.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
// @filename: file.tsx
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @libFiles: react.d.ts,lib.d.ts
|
||||
|
||||
import React = require('react');
|
||||
|
||||
interface ButtonProp {
|
||||
a: number,
|
||||
b: string,
|
||||
children: Button;
|
||||
}
|
||||
|
||||
class Button extends React.Component<ButtonProp, any> {
|
||||
render() {
|
||||
// Error children are specified twice
|
||||
return (<InnerButton {...this.props} children="hi">
|
||||
<div>Hello World</div>
|
||||
</InnerButton>);
|
||||
}
|
||||
}
|
||||
|
||||
interface InnerButtonProp {
|
||||
a: number
|
||||
}
|
||||
|
||||
class InnerButton extends React.Component<InnerButtonProp, any> {
|
||||
render() {
|
||||
return (<button>Hello</button>);
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,22 @@ interface ComponentProps {
|
||||
}
|
||||
|
||||
export default function Component(props: ComponentProps) {
|
||||
return (
|
||||
<AnotherComponent {...props} />
|
||||
);
|
||||
let condition1: boolean;
|
||||
if (condition1) {
|
||||
return (
|
||||
<ChildComponent {...props} />
|
||||
);
|
||||
}
|
||||
else {
|
||||
return (<ChildComponent {...props} property1="NewString" />);
|
||||
}
|
||||
}
|
||||
|
||||
interface AnotherComponentProps {
|
||||
property1: string;
|
||||
}
|
||||
|
||||
function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
function ChildComponent({ property1 }: AnotherComponentProps) {
|
||||
return (
|
||||
<span>{property1}</span>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// @filename: file.tsx
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @libFiles: react.d.ts,lib.d.ts
|
||||
|
||||
import React = require('react');
|
||||
|
||||
interface ComponentProps {
|
||||
property1: string;
|
||||
property2: number;
|
||||
}
|
||||
|
||||
export default function Component(props: ComponentProps) {
|
||||
return (
|
||||
// Error: missing property
|
||||
<AnotherComponent {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
interface AnotherComponentProps {
|
||||
property1: string;
|
||||
AnotherProperty1: string;
|
||||
property2: boolean;
|
||||
}
|
||||
|
||||
function AnotherComponent({ property1 }: AnotherComponentProps) {
|
||||
return (
|
||||
<span>{property1}</span>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user