File tree Expand file tree Collapse file tree 10 files changed +351
-1
lines changed Expand file tree Collapse file tree 10 files changed +351
-1
lines changed Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface Prop {
9
+ a : number ,
10
+ b : string ,
11
+ children : string | JSX . Element
12
+ }
13
+
14
+ function Comp ( p : Prop ) {
15
+ return < div > { p . b } </ div > ;
16
+ }
17
+
18
+ // OK
19
+ let k = < Comp a = { 10 } b = "hi" children = "lol" /> ;
20
+ let k1 =
21
+ < Comp a = { 10 } b = "hi" >
22
+ hi hi hi!
23
+ </ Comp > ;
24
+ let k2 =
25
+ < Comp a = { 10 } b = "hi" >
26
+ < div > hi hi hi!</ div >
27
+ </ Comp > ;
Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface Prop {
9
+ a : number ,
10
+ b : string ,
11
+ children : string | JSX . Element
12
+ }
13
+
14
+ function Comp ( p : Prop ) {
15
+ return < div > { p . b } </ div > ;
16
+ }
17
+
18
+ // Error: missing children
19
+ let k = < Comp a = { 10 } b = "hi" /> ;
20
+
21
+ let k1 =
22
+ < Comp a = { 10 } b = "hi" children = "Random" >
23
+ hi hi hi!
24
+ </ Comp > ;
25
+
26
+ // Error: incorrect type
27
+ let k2 =
28
+ < Comp a = { 10 } b = "hi" >
29
+ < div > My Div </ div >
30
+ { ( name : string ) => < div > My name { name } </ div > }
31
+ </ Comp > ;
32
+
33
+ let k3 =
34
+ < Comp a = { 10 } b = "hi" >
35
+ < div > My Div </ div >
36
+ { 1000000 }
37
+ </ Comp > ;
38
+
39
+ let k4 =
40
+ < Comp a = { 10 } b = "hi" >
41
+ < div > My Div </ div >
42
+ hi hi hi!
43
+ </ Comp > ;
44
+
45
+ let k5 =
46
+ < Comp a = { 10 } b = "hi" >
47
+ < div > My Div </ div >
48
+ < div > My Div </ div >
49
+ </ Comp > ;
Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface IUser {
9
+ Name : string ;
10
+ }
11
+
12
+ interface IFetchUserProps {
13
+ children : ( user : IUser ) => JSX . Element ;
14
+ }
15
+
16
+ class FetchUser extends React . Component < IFetchUserProps , any > {
17
+ render ( ) {
18
+ return this . state
19
+ ? this . props . children ( this . state . result )
20
+ : null ;
21
+ }
22
+ }
23
+
24
+ // Ok
25
+ function UserName0 ( ) {
26
+ return (
27
+ < FetchUser >
28
+ { user => (
29
+ < h1 > { user . Name } </ h1 >
30
+ ) }
31
+ </ FetchUser >
32
+ ) ;
33
+ }
34
+
35
+ function UserName1 ( ) {
36
+ return (
37
+ < FetchUser >
38
+
39
+ { user => (
40
+ < h1 > { user . Name } </ h1 >
41
+ ) }
42
+ </ FetchUser >
43
+ ) ;
44
+ }
Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface IUser {
9
+ Name : string ;
10
+ }
11
+
12
+ interface IFetchUserProps {
13
+ children : ( user : IUser ) => JSX . Element ;
14
+ }
15
+
16
+ class FetchUser extends React . Component < IFetchUserProps , any > {
17
+ render ( ) {
18
+ return this . state
19
+ ? this . props . children ( this . state . result )
20
+ : null ;
21
+ }
22
+ }
23
+
24
+ // Error
25
+ function UserName ( ) {
26
+ return (
27
+ < FetchUser >
28
+ { user => (
29
+ < h1 > { user . NAme } </ h1 >
30
+ ) }
31
+ </ FetchUser >
32
+ ) ;
33
+ }
34
+
35
+ function UserName1 ( ) {
36
+ return (
37
+ < FetchUser >
38
+
39
+
40
+
41
+ { user => (
42
+ < h1 > { user . Name } </ h1 >
43
+ ) }
44
+ { user => (
45
+ < h1 > { user . Name } </ h1 >
46
+ ) }
47
+ </ FetchUser >
48
+ ) ;
49
+ }
Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface Prop {
9
+ a : number ,
10
+ b : string ,
11
+ children : Button ;
12
+ }
13
+
14
+ class Button extends React . Component < any , any > {
15
+ render ( ) {
16
+ return ( < div > My Button</ div > )
17
+ }
18
+ }
19
+
20
+ function Comp ( p : Prop ) {
21
+ return < div > { p . b } </ div > ;
22
+ }
23
+
24
+ // Error: no children specified
25
+ let k = < Comp a = { 10 } b = "hi" /> ;
26
+
27
+ // Error: JSX.element is not the same as JSX.ElementClass
28
+ let k1 =
29
+ < Comp a = { 10 } b = "hi" >
30
+ < Button />
31
+ </ Comp > ;
32
+ let k2 =
33
+ < Comp a = { 10 } b = "hi" >
34
+ { Button }
35
+ </ Comp > ;
Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface Prop {
9
+ a : number ,
10
+ b : string ,
11
+ children : JSX . Element | JSX . Element [ ] ;
12
+ }
13
+
14
+ class Button extends React . Component < any , any > {
15
+ render ( ) {
16
+ return ( < div > My Button</ div > )
17
+ }
18
+ }
19
+
20
+ function AnotherButton ( p : any ) {
21
+ return < h1 > Just Another Button</ h1 > ;
22
+ }
23
+
24
+ function Comp ( p : Prop ) {
25
+ return < div > { p . b } </ div > ;
26
+ }
27
+
28
+ // Ok
29
+ let k1 =
30
+ < Comp a = { 10 } b = "hi" >
31
+ < Button />
32
+ < AnotherButton />
33
+ </ Comp > ;
34
+
35
+ let k2 =
36
+ < Comp a = { 10 } b = "hi" >
37
+
38
+
39
+
40
+ < Button />
41
+ < AnotherButton />
42
+ </ Comp > ;
43
+
44
+ let k3 = < Comp a = { 10 } b = "hi" > < Button />
45
+ < AnotherButton />
46
+ </ Comp > ;
47
+
48
+ let k4 = < Comp a = { 10 } b = "hi" > < Button /> </ Comp > ;
Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface Prop {
9
+ a : number ,
10
+ b : string ,
11
+ children : JSX . Element | JSX . Element [ ] ;
12
+ }
13
+
14
+ class Button extends React . Component < any , any > {
15
+ render ( ) {
16
+ return ( < div > My Button</ div > )
17
+ }
18
+ }
19
+
20
+ function AnotherButton ( p : any ) {
21
+ return < h1 > Just Another Button</ h1 > ;
22
+ }
23
+
24
+ function Comp ( p : Prop ) {
25
+ return < div > { p . b } </ div > ;
26
+ }
27
+
28
+ // Error: whitespaces matters
29
+ let k1 = < Comp a = { 10 } b = "hi" > < Button /> < AnotherButton /> </ Comp > ;
30
+ let k2 = < Comp a = { 10 } b = "hi" > < Button />
31
+ < AnotherButton /> </ Comp > ;
32
+ let k3 = < Comp a = { 10 } b = "hi" > < Button />
33
+ < AnotherButton /> </ Comp > ;
Original file line number Diff line number Diff line change
1
+ // @filename : file.tsx
2
+ // @jsx : preserve
3
+ // @noLib : true
4
+ // @libFiles : react.d.ts,lib.d.ts
5
+
6
+ import React = require( 'react' ) ;
7
+
8
+ interface Prop {
9
+ a : number ,
10
+ b : string ,
11
+ children : string | JSX . Element | ( string | JSX . Element ) [ ] ;
12
+ }
13
+
14
+ class Button extends React . Component < any , any > {
15
+ render ( ) {
16
+ return ( < div > My Button</ div > )
17
+ }
18
+ }
19
+
20
+ function AnotherButton ( p : any ) {
21
+ return < h1 > Just Another Button</ h1 > ;
22
+ }
23
+
24
+ function Comp ( p : Prop ) {
25
+ return < div > { p . b } </ div > ;
26
+ }
27
+
28
+ // OK
29
+ let k1 = < Comp a = { 10 } b = "hi" > < Button /> < AnotherButton /> </ Comp > ;
30
+ let k2 = < Comp a = { 10 } b = "hi" > < Button />
31
+ < AnotherButton /> </ Comp > ;
32
+ let k3 = < Comp a = { 10 } b = "hi" > < Button />
33
+ < AnotherButton /> </ Comp > ;
34
+ let k4 = < Comp a = { 10 } b = "hi" > < Button /> </ Comp > ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ const b6 = <MainButton {...obj2} />;
55
55
const b7 = < MainButton { ...{ onClick : ( ) => { console . log ( "hi" ) } } } /> ;
56
56
const b8 = < MainButton { ...{ onClick ( ) { } } } /> ; // OK; method declaration get retained (See GitHub #13365)
57
57
const b9 = < MainButton to = '/some/path' extra-prop > GO</ MainButton > ;
58
- const b10 = < MainButton to = '/some/path' children = "hi" > GO </ MainButton > ;
58
+ const b10 = < MainButton to = '/some/path' children = "hi" > </ MainButton > ;
59
59
const b11 = < MainButton onClick = { ( e ) => { } } className = "hello" data-format > Hello world</ MainButton > ;
60
60
const b12 = < MainButton data-format = "Hello world" />
61
61
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+ //@module : commonjs
3
+ //@jsx : preserve
4
+
5
+ // @Filename : 1.tsx
6
+ //// declare module JSX {
7
+ //// interface Element { }
8
+ //// interface IntrinsicElements {
9
+ //// }
10
+ //// interface ElementAttributesProperty { props; }
11
+ //// }
12
+ //// interface IUser {
13
+ //// Name: string;
14
+ //// }
15
+ //// interface IFetchUserProps {
16
+ //// children: (user: IUser) => any;
17
+ //// }
18
+ //// function FetchUser(props: IFetchUserProps) { return undefined; }
19
+ //// function UserName() {
20
+ //// return (
21
+ //// <FetchUser>
22
+ //// { user => (
23
+ //// <h1>{ user./**/ }</h1>
24
+ //// ) }
25
+ //// </FetchUser>
26
+ //// );
27
+ //// }
28
+
29
+ goTo . marker ( ) ;
30
+ debugger ;
31
+ verify . completionListContains ( 'Name' ) ;
You can’t perform that action at this time.
0 commit comments