mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
77 lines
3.0 KiB
Plaintext
77 lines
3.0 KiB
Plaintext
file.tsx(16,10): error TS2741: Property 'children' is missing in type '{ a: number; b: string; }' but required in type 'Prop'.
|
|
file.tsx(19,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
|
|
file.tsx(33,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
file.tsx(39,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
file.tsx(45,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
file.tsx(51,6): error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
|
|
|
|
==== file.tsx (6 errors) ====
|
|
/// <reference path="/.lib/react.d.ts" />
|
|
|
|
import React = require('react');
|
|
|
|
interface Prop {
|
|
a: number,
|
|
b: string,
|
|
children: string | JSX.Element
|
|
}
|
|
|
|
function Comp(p: Prop) {
|
|
return <div>{p.b}</div>;
|
|
}
|
|
|
|
// Error: missing children
|
|
let k = <Comp a={10} b="hi" />;
|
|
~~~~
|
|
!!! error TS2741: Property 'children' is missing in type '{ a: number; b: string; }' but required in type 'Prop'.
|
|
!!! related TS2728 file.tsx:8:5: 'children' is declared here.
|
|
|
|
let k0 =
|
|
<Comp a={10} b="hi" children="Random" >
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten.
|
|
hi hi hi!
|
|
</Comp>;
|
|
|
|
let o = {
|
|
children:"Random"
|
|
}
|
|
let k1 =
|
|
<Comp a={10} b="hi" {...o} >
|
|
hi hi hi!
|
|
</Comp>;
|
|
|
|
// Error: incorrect type
|
|
let k2 =
|
|
<Comp a={10} b="hi">
|
|
~~~~
|
|
!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
<div> My Div </div>
|
|
{(name: string) => <div> My name {name} </div>}
|
|
</Comp>;
|
|
|
|
let k3 =
|
|
<Comp a={10} b="hi">
|
|
~~~~
|
|
!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
<div> My Div </div>
|
|
{1000000}
|
|
</Comp>;
|
|
|
|
let k4 =
|
|
<Comp a={10} b="hi" >
|
|
~~~~
|
|
!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
<div> My Div </div>
|
|
hi hi hi!
|
|
</Comp>;
|
|
|
|
let k5 =
|
|
<Comp a={10} b="hi" >
|
|
~~~~
|
|
!!! error TS2746: This JSX tag's 'children' prop expects a single child of type 'string | Element', but multiple children were provided.
|
|
<div> My Div </div>
|
|
<div> My Div </div>
|
|
</Comp>;
|
|
|