8000 JSX and `as` operator by RyanCavanaugh · Pull Request #3564 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

JSX and as operator #3564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Jun 29, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
556cb70
Utilities + types setup for JSX and As
RyanCavanaugh Jun 18, 2015
a4045e5
Scanner / parser for JSX and As
RyanCavanaugh Jun 18, 2015
6dfe3d7
JSX/as support in tsc.js + error messages
RyanCavanaugh Jun 18, 2015
195db03
Checker work for JSX + As
RyanCavanaugh Jun 18, 2015
f5336db
Emitter for JSX
RyanCavanaugh Jun 18, 2015
6d01a44
Formatting and LS for JSX and As
RyanCavanaugh Jun 18, 2015
e34d8cd
Test support for TSX files
RyanCavanaugh Jun 18, 2015
fa198a5
Fourslash tests for JSX and As
RyanCavanaugh Jun 18, 2015
2b44dca
Conformance tests for 'as' operator
RyanCavanaugh Jun 18, 2015
bc9b53a
Conformance tests for JSX
RyanCavanaugh Jun 18, 2015
a5c44a3
Baseline-accept
RyanCavanaugh Jun 18, 2015
8000 46eb521
Missed a few files in baseline-accept
RyanCavanaugh Jun 18, 2015
b0750c2
Fix emit for boolean attributes
RyanCavanaugh Jun 19, 2015
388e73f
Fix React emit for spread attributes when they are the first attribute
RyanCavanaugh Jun 19, 2015
2555344
Misc cleanup
RyanCavanaugh Jun 22, 2015
e448d8b
Treat </ as a token in TSX files
RyanCavanaugh Jun 22, 2015
c9a925e
Unrelated baseline noise
RyanCavanaugh Jun 22, 2015
16c8344
More cleanup
RyanCavanaugh Jun 22, 2015
5bc10b9
It's no longer safe to store JSX elem. attr. type in nodelinks.resolv…
RyanCavanaugh Jun 22, 2015
b3ca009
Merge remote-tracking branch 'upstream/master' into jsxAndAs
RyanCavanaugh Jun 23, 2015
65828c4
Spreaded anys should satisfy all required properties
RyanCavanaugh Jun 24, 2015
8180b7d
Don't error on JSX elements when JSX.Element isn't present
RyanCavanaugh Jun 25, 2015
b1a05b8
Improve commandline help for --jsx
RyanCavanaugh Jun 26, 2015
306de4d
CR feedback
RyanCavanaugh Jun 26, 2015
ce6f39e
Move token scan to inside `if`
RyanCavanaugh Jun 26, 2015
042f1fc
Update for style :tophat:
RyanCavanaugh Jun 29, 2015
634d35a
Merge remote-tracking branch 'upstream/master' into jsxAndAs
RyanCavanaugh Jun 29, 2015
1d09c6e
Don't use ES5 array APIs
RyanCavanaugh Jun 29, 2015
3402f35
Missed a file in merge; use Tristate.True in arrow fn check
RyanCavanaugh Jun 29, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix React emit for spread attributes when they are the first attribute
  • Loading branch information
RyanCavanaugh committed Jun 19, 2015
commit 388e73f49f9857f2ae2783af0d0812ed83952ad1
5 changes: 5 additions & 0 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
let haveOpenedObjectLiteral = false;
for (var i = 0; i < attrs.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use let

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

if (attrs[i].kind === SyntaxKind.JsxSpreadAttribute) {
// If this is the first argument, we need to emit a {} as the first argument
if(i === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after if

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe t 10000 his comment to others. Learn more.

✔️

write('{}, ');
}

if (haveOpenedObjectLiteral) {
write('}');
haveOpenedObjectLiteral = false;
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/tsxReactEmit2.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ var spreads5 = <div x={p2} {...p1} y={p3}>{p2}</div>;

//// [tsxReactEmit2.js]
var p1, p2, p3;
var spreads1 = React.createElement("div", React.__spread(p1), p2);
var spreads2 = React.createElement("div", React.__spread(p1), p2);
var spreads1 = React.createElement("div", React.__spread({}, p1), p2);
var spreads2 = React.createElement("div", React.__spread({}, p1), p2);
var spreads3 = React.createElement("div", React.__spread({x: p3}, p1), p2);
var spreads4 = React.createElement("div", React.__spread(p1, {x: p3}), p2);
var spreads4 = React.createElement("div", React.__spread({}, p1, {x: p3}), p2);
var spreads5 = React.createElement("div", React.__spread({x: p2}, p1, {y: p3}), p2);
4 changes: 3 additions & 1 deletion tests/baselines/reference/tsxReactEmit4.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ tests/cases/conformance/jsx/tsxReactEmit4.tsx(11,5): error TS2304: Cannot find n
!!! error TS2304: Cannot find name 'blah'.

</div>;


// Should emit React.__spread({}, p, {x: 0})
var spread1 = <div {...p} x={0} />;
6 changes: 5 additions & 1 deletion tests/baselines/reference/tsxReactEmit4.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ var openClosed1 = <div>
{blah}

</div>;


// Should emit React.__spread({}, p, {x: 0})
var spread1 = <div {...p} x={0} />;

//// [tsxReactEmit4.js]
var p;
var openClosed1 = React.createElement("div", null, blah);
// Should emit React.__spread({}, p, {x: 0})
var spread1 = React.createElement("div", React.__spread({}, p, {x: 0}));
3 changes: 3 additions & 0 deletions tests/cases/conformance/jsx/tsxReactEmit4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ var openClosed1 = <div>
{blah}

</div>;

// Should emit React.__spread({}, p, {x: 0})
var spread1 = <div {...p} x={0} />;
0