mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-18 03:43:28 -06:00
Update tests
This commit is contained in:
parent
abb3f58db2
commit
269d37a2e6
@ -1,4 +0,0 @@
|
||||
//@jsx: react
|
||||
|
||||
declare var React: any;
|
||||
<div></div>;
|
||||
48
tests/cases/conformance/jsx/checkJsxChildrenProperty14.tsx
Normal file
48
tests/cases/conformance/jsx/checkJsxChildrenProperty14.tsx
Normal file
@ -0,0 +1,48 @@
|
||||
// @filename: file.tsx
|
||||
// @jsx: preserve
|
||||
// @noLib: true
|
||||
// @skipLibCheck: true
|
||||
// @libFiles: react.d.ts,lib.d.ts
|
||||
|
||||
import React = require('react');
|
||||
|
||||
interface Prop {
|
||||
a: number,
|
||||
b: string,
|
||||
children: JSX.Element | JSX.Element[];
|
||||
}
|
||||
|
||||
class Button extends React.Component<any, any> {
|
||||
render() {
|
||||
return (<div>My Button</div>)
|
||||
}
|
||||
}
|
||||
|
||||
function AnotherButton(p: any) {
|
||||
return <h1>Just Another Button</h1>;
|
||||
}
|
||||
|
||||
function Comp(p: Prop) {
|
||||
return <div>{p.b}</div>;
|
||||
}
|
||||
|
||||
// OK
|
||||
let k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>;
|
||||
let k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>;
|
||||
let k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>;
|
||||
|
||||
interface SingleChildProp {
|
||||
a: number,
|
||||
b: string,
|
||||
children: JSX.Element;
|
||||
}
|
||||
|
||||
function SingleChildComp(p: SingleChildProp) {
|
||||
return <div>{p.b}</div>;
|
||||
}
|
||||
|
||||
// OK
|
||||
let k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>;
|
||||
|
||||
// Errors
|
||||
let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>;
|
||||
14
tests/cases/conformance/jsx/tsxFragmentErrors.tsx
Normal file
14
tests/cases/conformance/jsx/tsxFragmentErrors.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
//@filename: file.tsx
|
||||
//@jsx: react
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
declare var React: any;
|
||||
|
||||
<>hi</div> // Error
|
||||
|
||||
<>eof // Error
|
||||
17
tests/cases/conformance/jsx/tsxFragmentPreserveEmit.tsx
Normal file
17
tests/cases/conformance/jsx/tsxFragmentPreserveEmit.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
//@filename: file.tsx
|
||||
//@jsx: preserve
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
declare var React: any;
|
||||
|
||||
<></>; // no whitespace
|
||||
< ></ >; // lots of whitespace
|
||||
< /*starting wrap*/ ></ /*ending wrap*/>; // comments in the tags
|
||||
<>hi</>; // text inside
|
||||
<><span>hi</span><div>bye</div></>; // children
|
||||
<><span>1</span><><span>2.1</span><span>2.2</span></><span>3</span></>; // nested fragments
|
||||
17
tests/cases/conformance/jsx/tsxFragmentReactEmit.tsx
Normal file
17
tests/cases/conformance/jsx/tsxFragmentReactEmit.tsx
Normal file
@ -0,0 +1,17 @@
|
||||
//@filename: file.tsx
|
||||
//@jsx: react
|
||||
|
||||
declare module JSX {
|
||||
interface Element { }
|
||||
interface IntrinsicElements {
|
||||
[s: string]: any;
|
||||
}
|
||||
}
|
||||
declare var React: any;
|
||||
|
||||
<></>; // no whitespace
|
||||
< ></ >; // lots of whitespace
|
||||
< /*starting wrap*/ ></ /*ending wrap*/>; // comments in the tags
|
||||
<>hi</>; // text inside
|
||||
<><span>hi</span><div>bye</div></>; // children
|
||||
<><span>1</span><><span>2.1</span><span>2.2</span></><span>3</span></>; // nested fragments
|
||||
Loading…
x
Reference in New Issue
Block a user