|
| 1 | +=== tests/cases/conformance/jsx/file.tsx === |
| 2 | +import React = require('react'); |
| 3 | +>React : Symbol(React, Decl(file.tsx, 0, 0)) |
| 4 | + |
| 5 | +interface Prop { |
| 6 | +>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) |
| 7 | + |
| 8 | + a: number, |
| 9 | +>a : Symbol(Prop.a, Decl(file.tsx, 2, 16)) |
| 10 | + |
| 11 | + b: string, |
| 12 | +>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) |
| 13 | + |
| 14 | + children: JSX.Element | JSX.Element[]; |
| 15 | +>children : Symbol(Prop.children, Decl(file.tsx, 4, 14)) |
| 16 | +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) |
| 17 | +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) |
| 18 | +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) |
| 19 | +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) |
| 20 | +} |
| 21 | + |
| 22 | +class Button extends React.Component<any, any> { |
| 23 | +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) |
| 24 | +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) |
| 25 | +>React : Symbol(React, Decl(file.tsx, 0, 0)) |
| 26 | +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) |
| 27 | + |
| 28 | + render() { |
| 29 | +>render : Symbol(Button.render, Decl(file.tsx, 8, 48)) |
| 30 | + |
| 31 | + return (<div>My Button</div>) |
| 32 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 33 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +function AnotherButton(p: any) { |
| 38 | +>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1)) |
| 39 | +>p : Symbol(p, Decl(file.tsx, 14, 23)) |
| 40 | + |
| 41 | + return <h1>Just Another Button</h1>; |
| 42 | +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) |
| 43 | +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) |
| 44 | +} |
| 45 | + |
| 46 | +function Comp(p: Prop) { |
| 47 | +>Comp : Symbol(Comp, Decl(file.tsx, 16, 1)) |
| 48 | +>p : Symbol(p, Decl(file.tsx, 18, 14)) |
| 49 | +>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) |
| 50 | + |
| 51 | + return <div>{p.b}</div>; |
| 52 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 53 | +>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) |
| 54 | +>p : Symbol(p, Decl(file.tsx, 18, 14)) |
| 55 | +>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) |
| 56 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 57 | +} |
| 58 | + |
| 59 | +// OK |
| 60 | +let k1 = <Comp a={10} b="hi"><></><Button /><AnotherButton /></Comp>; |
| 61 | +>k1 : Symbol(k1, Decl(file.tsx, 23, 3)) |
| 62 | +>Comp : Symbol(Comp, Decl(file.tsx, 16, 1)) |
| 63 | +>a : Symbol(a, Decl(file.tsx, 23, 14)) |
| 64 | +>b : Symbol(b, Decl(file.tsx, 23, 21)) |
| 65 | +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) |
| 66 | +>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1)) |
| 67 | +>Comp : Symbol(Comp, Decl(file.tsx, 16, 1)) |
| 68 | + |
| 69 | +let k2 = <Comp a={10} b="hi"><><Button /></><AnotherButton /></Comp>; |
| 70 | +>k2 : Symbol(k2, Decl(file.tsx, 24, 3)) |
| 71 | +>Comp : Symbol(Comp, Decl(file.tsx, 16, 1)) |
| 72 | +>a : Symbol(a, Decl(file.tsx, 24, 14)) |
| 73 | +>b : Symbol(b, Decl(file.tsx, 24, 21)) |
| 74 | +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) |
| 75 | +>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1)) |
| 76 | +>Comp : Symbol(Comp, Decl(file.tsx, 16, 1)) |
| 77 | + |
| 78 | +let k3 = <Comp a={10} b="hi"><><Button /><AnotherButton /></></Comp>; |
| 79 | +>k3 : Symbol(k3, Decl(file.tsx, 25, 3)) |
| 80 | +>Comp : Symbol(Comp, Decl(file.tsx, 16, 1)) |
| 81 | +>a : Symbol(a, Decl(file.tsx, 25, 14)) |
| 82 | +>b : Symbol(b, Decl(file.tsx, 25, 21)) |
| 83 | +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) |
| 84 | +>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1)) |
| 85 | +>Comp : Symbol(Comp, Decl(file.tsx, 16, 1)) |
| 86 | + |
| 87 | +interface SingleChildProp { |
| 88 | +>SingleChildProp : Symbol(SingleChildProp, Decl(file.tsx, 25, 69)) |
| 89 | + |
| 90 | + a: number, |
| 91 | +>a : Symbol(SingleChildProp.a, Decl(file.tsx, 27, 27)) |
| 92 | + |
| 93 | + b: string, |
| 94 | +>b : Symbol(SingleChildProp.b, Decl(file.tsx, 28, 14)) |
| 95 | + |
| 96 | + children: JSX.Element; |
| 97 | +>children : Symbol(SingleChildProp.children, Decl(file.tsx, 29, 14)) |
| 98 | +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) |
| 99 | +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) |
| 100 | +} |
| 101 | + |
| 102 | +function SingleChildComp(p: SingleChildProp) { |
| 103 | +>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1)) |
| 104 | +>p : Symbol(p, Decl(file.tsx, 33, 25)) |
| 105 | +>SingleChildProp : Symbol(SingleChildProp, Decl(file.tsx, 25, 69)) |
| 106 | + |
| 107 | + return <div>{p.b}</div>; |
| 108 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 109 | +>p.b : Symbol(SingleChildProp.b, Decl(file.tsx, 28, 14)) |
| 110 | +>p : Symbol(p, Decl(file.tsx, 33, 25)) |
| 111 | +>b : Symbol(SingleChildProp.b, Decl(file.tsx, 28, 14)) |
| 112 | +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) |
| 113 | +} |
| 114 | + |
| 115 | +// OK |
| 116 | +let k4 = <SingleChildComp a={10} b="hi"><><Button /><AnotherButton /></></SingleChildComp>; |
| 117 | +>k4 : Symbol(k4, Decl(file.tsx, 38, 3)) |
| 118 | +>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1)) |
| 119 | +>a : Symbol(a, Decl(file.tsx, 38, 25)) |
| 120 | +>b : Symbol(b, Decl(file.tsx, 38, 32)) |
| 121 | +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) |
| 122 | +>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1)) |
| 123 | +>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1)) |
| 124 | + |
| 125 | +// Error |
| 126 | +let k5 = <SingleChildComp a={10} b="hi"><></><Button /><AnotherButton /></SingleChildComp>; |
| 127 | +>k5 : Symbol(k5, Decl(file.tsx, 41, 3)) |
| 128 | +>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1)) |
| 129 | +>a : Symbol(a, Decl(file.tsx, 41, 25)) |
| 130 | +>b : Symbol(b, Decl(file.tsx, 41, 32)) |
| 131 | +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) |
| 132 | +>AnotherButton : Symbol(AnotherButton, Decl(file.tsx, 12, 1)) |
| 133 | +>SingleChildComp : Symbol(SingleChildComp, Decl(file.tsx, 31, 1)) |
| 134 | + |
0 commit comments