mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
42 lines
2.0 KiB
Plaintext
42 lines
2.0 KiB
Plaintext
file.tsx(26,40): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'.
|
|
file.tsx(28,22): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'.
|
|
file.tsx(29,30): error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'.
|
|
|
|
|
|
==== file.tsx (3 errors) ====
|
|
/// <reference path="/.lib/react.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>;
|
|
}
|
|
|
|
// Error: whitespaces matters
|
|
let k1 = <Comp a={10} b="hi"><Button /> <AnotherButton /></Comp>;
|
|
~~
|
|
!!! error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'.
|
|
let k2 = <Comp a={10} b="hi"><Button />
|
|
<AnotherButton /> </Comp>;
|
|
~~
|
|
!!! error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'.
|
|
let k3 = <Comp a={10} b="hi"> <Button />
|
|
~~~~
|
|
!!! error TS2747: 'Comp' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element[] | Element'.
|
|
<AnotherButton /></Comp>; |