File: checkJsxChildrenProperty7.errors.txt

package info (click to toggle)
node-typescript 5.0.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 459,140 kB
  • sloc: javascript: 1,972,754; makefile: 6; sh: 1
file content (40 lines) | stat: -rw-r--r-- 2,080 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
tests/cases/conformance/jsx/file.tsx(24,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[]'.
tests/cases/conformance/jsx/file.tsx(26,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[]'.
tests/cases/conformance/jsx/file.tsx(27,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[]'.


==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
    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>;