-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15160 from Microsoft/master-jsxChildren
[Master] Type checking JSX children
- Loading branch information
Showing
77 changed files
with
3,064 additions
and
239 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//// [file.tsx] | ||
import React = require('react'); | ||
|
||
interface Prop { | ||
a: number, | ||
b: string, | ||
children: string | JSX.Element | ||
} | ||
|
||
function Comp(p: Prop) { | ||
return <div>{p.b}</div>; | ||
} | ||
|
||
// OK | ||
let k = <Comp a={10} b="hi" children ="lol" />; | ||
let k1 = | ||
<Comp a={10} b="hi"> | ||
hi hi hi! | ||
</Comp>; | ||
let k2 = | ||
<Comp a={10} b="hi"> | ||
<div>hi hi hi!</div> | ||
</Comp>; | ||
|
||
//// [file.jsx] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var React = require("react"); | ||
function Comp(p) { | ||
return <div>{p.b}</div>; | ||
} | ||
// OK | ||
var k = <Comp a={10} b="hi" children="lol"/>; | ||
var k1 = <Comp a={10} b="hi"> | ||
hi hi hi! | ||
</Comp>; | ||
var k2 = <Comp a={10} b="hi"> | ||
<div>hi hi hi!</div> | ||
</Comp>; |
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/checkJsxChildrenProperty1.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
=== tests/cases/conformance/jsx/file.tsx === | ||
import React = require('react'); | ||
>React : Symbol(React, Decl(file.tsx, 0, 0)) | ||
|
||
interface Prop { | ||
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) | ||
|
||
a: number, | ||
>a : Symbol(Prop.a, Decl(file.tsx, 2, 16)) | ||
|
||
b: string, | ||
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) | ||
|
||
children: string | JSX.Element | ||
>children : Symbol(Prop.children, Decl(file.tsx, 4, 14)) | ||
>JSX : Symbol(JSX, Decl(react.d.ts, 2352, 1)) | ||
>Element : Symbol(JSX.Element, Decl(react.d.ts, 2355, 27)) | ||
} | ||
|
||
function Comp(p: Prop) { | ||
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) | ||
>p : Symbol(p, Decl(file.tsx, 8, 14)) | ||
>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) | ||
|
||
return <div>{p.b}</div>; | ||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) | ||
>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) | ||
>p : Symbol(p, Decl(file.tsx, 8, 14)) | ||
>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) | ||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) | ||
} | ||
|
||
// OK | ||
let k = <Comp a={10} b="hi" children ="lol" />; | ||
>k : Symbol(k, Decl(file.tsx, 13, 3)) | ||
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) | ||
>a : Symbol(a, Decl(file.tsx, 13, 13)) | ||
>b : Symbol(b, Decl(file.tsx, 13, 20)) | ||
>children : Symbol(children, Decl(file.tsx, 13, 27)) | ||
|
||
let k1 = | ||
>k1 : Symbol(k1, Decl(file.tsx, 14, 3)) | ||
|
||
<Comp a={10} b="hi"> | ||
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) | ||
>a : Symbol(a, Decl(file.tsx, 15, 9)) | ||
>b : Symbol(b, Decl(file.tsx, 15, 16)) | ||
|
||
hi hi hi! | ||
</Comp>; | ||
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) | ||
|
||
let k2 = | ||
>k2 : Symbol(k2, Decl(file.tsx, 18, 3)) | ||
|
||
<Comp a={10} b="hi"> | ||
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) | ||
>a : Symbol(a, Decl(file.tsx, 19, 9)) | ||
>b : Symbol(b, Decl(file.tsx, 19, 16)) | ||
|
||
<div>hi hi hi!</div> | ||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) | ||
>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) | ||
|
||
</Comp>; | ||
>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
=== tests/cases/conformance/jsx/file.tsx === | ||
import React = require('react'); | ||
>React : typeof React | ||
|
||
interface Prop { | ||
>Prop : Prop | ||
|
||
a: number, | ||
>a : number | ||
|
||
b: string, | ||
>b : string | ||
|
||
children: string | JSX.Element | ||
>children : string | JSX.Element | ||
>JSX : any | ||
>Element : JSX.Element | ||
} | ||
|
||
function Comp(p: Prop) { | ||
>Comp : (p: Prop) => JSX.Element | ||
>p : Prop | ||
>Prop : Prop | ||
|
||
return <div>{p.b}</div>; | ||
><div>{p.b}</div> : JSX.Element | ||
>div : any | ||
>p.b : string | ||
>p : Prop | ||
>b : string | ||
>div : any | ||
} | ||
|
||
// OK | ||
let k = <Comp a={10} b="hi" children ="lol" />; | ||
>k : JSX.Element | ||
><Comp a={10} b="hi" children ="lol" /> : JSX.Element | ||
>Comp : (p: Prop) => JSX.Element | ||
>a : number | ||
>10 : 10 | ||
>b : string | ||
>children : string | ||
|
||
let k1 = | ||
>k1 : JSX.Element | ||
|
||
<Comp a={10} b="hi"> | ||
><Comp a={10} b="hi"> hi hi hi! </Comp> : JSX.Element | ||
>Comp : (p: Prop) => JSX.Element | ||
>a : number | ||
>10 : 10 | ||
>b : string | ||
|
||
hi hi hi! | ||
</Comp>; | ||
>Comp : (p: Prop) => JSX.Element | ||
|
||
let k2 = | ||
>k2 : JSX.Element | ||
|
||
<Comp a={10} b="hi"> | ||
><Comp a={10} b="hi"> <div>hi hi hi!</div> </Comp> : JSX.Element | ||
>Comp : (p: Prop) => JSX.Element | ||
>a : number | ||
>10 : 10 | ||
>b : string | ||
|
||
<div>hi hi hi!</div> | ||
><div>hi hi hi!</div> : JSX.Element | ||
>div : any | ||
>div : any | ||
|
||
</Comp>; | ||
>Comp : (p: Prop) => JSX.Element | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//// [file.tsx] | ||
declare module JSX { | ||
interface Element { } | ||
interface ElementAttributesProperty { props: {} } | ||
interface IntrinsicElements { | ||
div: any; | ||
h2: any; | ||
h1: any; | ||
} | ||
} | ||
|
||
class Button { | ||
props: {} | ||
render() { | ||
return (<div>My Button</div>) | ||
} | ||
} | ||
|
||
// OK | ||
let k1 = <div> <h2> Hello </h2> <h1> world </h1></div>; | ||
let k2 = <div> <h2> Hello </h2> {(user: any) => <h2>{user.name}</h2>}</div>; | ||
let k3 = <div> {1} {"That is a number"} </div>; | ||
let k4 = <Button> <h2> Hello </h2> </Button>; | ||
|
||
//// [file.jsx] | ||
var Button = (function () { | ||
function Button() { | ||
} | ||
Button.prototype.render = function () { | ||
return (<div>My Button</div>); | ||
}; | ||
return Button; | ||
}()); | ||
// OK | ||
var k1 = <div> <h2> Hello </h2> <h1> world </h1></div>; | ||
var k2 = <div> <h2> Hello </h2> {function (user) { return <h2>{user.name}</h2>; }}</div>; | ||
var k3 = <div> {1} {"That is a number"} </div>; | ||
var k4 = <Button> <h2> Hello </h2> </Button>; |
Oops, something went wrong.