Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
7 changes: 3 additions & 4 deletions internal/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,9 @@ func (p *Printer) shouldEmitBlockFunctionBodyOnSingleLine(body *ast.Block) bool
}

func (p *Printer) shouldEmitOnNewLine(node *ast.Node, format ListFormat) bool {
// !!! TODO: enable multiline emit
// if p.emitContext.EmitFlags(node)&EFStartOnNewLine != 0 {
// return true
// }
if p.emitContext.EmitFlags(node)&EFStartOnNewLine != 0 {
return true
}
return format&LFPreferNewLine != 0
}

Expand Down
20 changes: 20 additions & 0 deletions testdata/baselines/reference/compiler/jsxNestedIndentation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//// [tests/cases/compiler/jsxNestedIndentation.tsx] ////

//// [jsxNestedIndentation.tsx]
declare var React: any;
declare function Child(props: { children?: any }): any;
function Test() {
return <Child>
<Child>
<Child></Child>
</Child>
</Child>
}


//// [jsxNestedIndentation.js]
function Test() {
return React.createElement(Child, null,
React.createElement(Child, null,
React.createElement(Child, null)));
}
31 changes: 31 additions & 0 deletions testdata/baselines/reference/compiler/jsxNestedIndentation.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//// [tests/cases/compiler/jsxNestedIndentation.tsx] ////

=== jsxNestedIndentation.tsx ===
declare var React: any;
>React : Symbol(React, Decl(jsxNestedIndentation.tsx, 0, 11))

declare function Child(props: { children?: any }): any;
>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23))
>props : Symbol(props, Decl(jsxNestedIndentation.tsx, 1, 23))
>children : Symbol(children, Decl(jsxNestedIndentation.tsx, 1, 31))

function Test() {
>Test : Symbol(Test, Decl(jsxNestedIndentation.tsx, 1, 55))

return <Child>
>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23))

<Child>
>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23))

<Child></Child>
>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23))
>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23))

</Child>
>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23))

</Child>
>Child : Symbol(Child, Decl(jsxNestedIndentation.tsx, 0, 23))
}

34 changes: 34 additions & 0 deletions testdata/baselines/reference/compiler/jsxNestedIndentation.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//// [tests/cases/compiler/jsxNestedIndentation.tsx] ////

=== jsxNestedIndentation.tsx ===
declare var React: any;
>React : any

declare function Child(props: { children?: any }): any;
>Child : (props: { children?: any; }) => any
>props : { children?: any; }
>children : any

function Test() {
>Test : () => any

return <Child>
><Child> <Child> <Child></Child> </Child> </Child> : any
>Child : (props: { children?: any; }) => any

<Child>
><Child> <Child></Child> </Child> : any
>Child : (props: { children?: any; }) => any

<Child></Child>
><Child></Child> : any
>Child : (props: { children?: any; }) => any
>Child : (props: { children?: any; }) => any

</Child>
>Child : (props: { children?: any; }) => any

</Child>
>Child : (props: { children?: any; }) => any
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Component {
//// [commentsOnJSXExpressionsArePreserved.js]
class Component {
render() {
return React.createElement("div", null, null /* preserved */);
return React.createElement("div", null,
null /* preserved */);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- old.commentsOnJSXExpressionsArePreserved(jsx=react,module=commonjs,moduledetection=auto).js
+++ new.commentsOnJSXExpressionsArePreserved(jsx=react,module=commonjs,moduledetection=auto).js
@@= skipped -24, +24 lines =@@
//// [commentsOnJSXExpressionsArePreserved.js]
class Component {
render() {
- return React.createElement("div", null, null /* preserved */);
+ return React.createElement("div", null,
+ null /* preserved */);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Component {
Object.defineProperty(exports, "__esModule", { value: true });
class Component {
render() {
return React.createElement("div", null, null /* preserved */);
return React.createElement("div", null,
null /* preserved */);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- old.commentsOnJSXExpressionsArePreserved(jsx=react,module=commonjs,moduledetection=force).js
+++ new.commentsOnJSXExpressionsArePreserved(jsx=react,module=commonjs,moduledetection=force).js
@@= skipped -26, +26 lines =@@
Object.defineProperty(exports, "__esModule", { value: true });
class Component {
render() {
- return React.createElement("div", null, null /* preserved */);
+ return React.createElement("div", null,
+ null /* preserved */);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Component {
//// [commentsOnJSXExpressionsArePreserved.js]
class Component {
render() {
return React.createElement("div", null, null /* preserved */);
return React.createElement("div", null,
null /* preserved */);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- old.commentsOnJSXExpressionsArePreserved(jsx=react,module=commonjs,moduledetection=legacy).js
+++ new.commentsOnJSXExpressionsArePreserved(jsx=react,module=commonjs,moduledetection=legacy).js
@@= skipped -24, +24 lines =@@
//// [commentsOnJSXExpressionsArePreserved.js]
class Component {
render() {
- return React.createElement("div", null, null /* preserved */);
+ return React.createElement("div", null,
+ null /* preserved */);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ let Foo = {
Bar() { }
};
let Baz = () => { };
let x = React.createElement(Foo.Bar, null, "Hello let y = ", React.createElement(Baz, null, "Hello"));
let x = React.createElement(Foo.Bar, null,
"Hello let y = ",
React.createElement(Baz, null, "Hello"));

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ configureStore({
});
const Component = () => {
const categories = ['Fruit', 'Vegetables'];
return (React.createElement("ul", null, React.createElement("li", null, "All"), categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only
))));
return (React.createElement("ul", null,
React.createElement("li", null, "All"),
categories.map((category) => (React.createElement("li", { key: category }, category) // Error about 'key' only
))));
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ declare var React: any;


//// [jsxAttributeWithoutExpressionReact.js]
React.createElement(View, null, React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true }));
React.createElement(View, null,
React.createElement(ListView, { refreshControl: React.createElement(RefreshControl, { onRefresh: true, refreshing: true }), dataSource: this.state.ds, renderRow: true }));

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ const a = (
//// [index.js]
/// <reference path="react18/react18.d.ts" />
/// <reference path="react18/global.d.ts" />
const a = (React.createElement("main", null, (React.createElement("div", null)), React.createElement("span", null)));
const a = (React.createElement("main", null,
(React.createElement("div", null)),
React.createElement("span", null)));
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@
-"use strict";
/// <reference path="react18/react18.d.ts" />
/// <reference path="react18/global.d.ts" />
-const a = (React.createElement("main", null,
- (React.createElement("div", null)),
- React.createElement("span", null)));
+const a = (React.createElement("main", null, (React.createElement("div", null)), React.createElement("span", null)));
const a = (React.createElement("main", null,
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ const b = (
//// [index.js]
/// <reference path="react18/react18.d.ts" />
/// <reference path="react18/global.d.ts" />
const b = (React.createElement(Foo, null, React.createElement("div", null), "aa"));
const b = (React.createElement(Foo, null,
React.createElement("div", null),
"aa"));
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@
-"use strict";
/// <reference path="react18/react18.d.ts" />
/// <reference path="react18/global.d.ts" />
-const b = (React.createElement(Foo, null,
- React.createElement("div", null),
- "aa"));
+const b = (React.createElement(Foo, null, React.createElement("div", null), "aa"));
const b = (React.createElement(Foo, null,
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,35 @@ function Blah(props) {
return React.createElement(React.Fragment, null);
}
// Incompatible child.
var a = React.createElement(Blah, null, x => x);
var a = React.createElement(Blah, null,
x => x);
// Blah components don't accept text as child elements
var a = React.createElement(Blah, null, "Hello unexpected text!");
// Blah components don't accept multiple children.
var a = React.createElement(Blah, null, x => "" + x, x => "" + x);
var a = React.createElement(Blah, null,
x => "" + x,
x => "" + x);
function Blah2(props) {
return React.createElement(React.Fragment, null);
}
// Incompatible child.
var a = React.createElement(Blah2, null, x => x);
var a = React.createElement(Blah2, null,
x => x);
// Blah2 components don't accept text as child elements
var a = React.createElement(Blah2, null, "Hello unexpected text!");
// Blah2 components don't accept multiple children of the wrong type.
var a = React.createElement(Blah2, null, x => x, x => x);
var a = React.createElement(Blah2, null,
x => x,
x => x);
function Blah3(props) {
return React.createElement(React.Fragment, null);
}
// Incompatible child.
var a = React.createElement(Blah3, null, x => x);
var a = React.createElement(Blah3, null,
x => x);
// Blah3 components don't accept text as child elements
var a = React.createElement(Blah3, null, "Hello unexpected text!");
// Blah3 components don't accept multiple children of the wrong type.
var a = React.createElement(Blah3, null, x => x, x => x);
var a = React.createElement(Blah3, null,
x => x,
x => x);
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,30 @@
function Blah(props) {
return React.createElement(React.Fragment, null);
}
@@= skipped -9, +9 lines =@@
// Incompatible child.
-var a = React.createElement(Blah, null, x => x);
+var a = React.createElement(Blah, null,
+ x => x);
// Blah components don't accept text as child elements
var a = React.createElement(Blah, null, "Hello unexpected text!");
// Blah components don't accept multiple children.
-var a = React.createElement(Blah, null,
- x => "" + x,
- x => "" + x);
+var a = React.createElement(Blah, null, x => "" + x, x => "" + x);
function Blah2(props) {
@@= skipped -16, +17 lines =@@
return React.createElement(React.Fragment, null);
}
@@= skipped -11, +9 lines =@@
// Incompatible child.
-var a = React.createElement(Blah2, null, x => x);
+var a = React.createElement(Blah2, null,
+ x => x);
// Blah2 components don't accept text as child elements
var a = React.createElement(Blah2, null, "Hello unexpected text!");
// Blah2 components don't accept multiple children of the wrong type.
-var a = React.createElement(Blah2, null,
- x => x,
- x => x);
+var a = React.createElement(Blah2, null, x => x, x => x);
function Blah3(props) {
@@= skipped -11, +12 lines =@@
return React.createElement(React.Fragment, null);
}
@@= skipped -11, +9 lines =@@
// Incompatible child.
-var a = React.createElement(Blah3, null, x => x);
+var a = React.createElement(Blah3, null,
+ x => x);
// Blah3 components don't accept text as child elements
var a = React.createElement(Blah3, null, "Hello unexpected text!");
// Blah3 components don't accept multiple children of the wrong type.
-var a = React.createElement(Blah3, null,
- x => x,
- x => x);
+var a = React.createElement(Blah3, null, x => x, x => x);
// Blah3 components don't accept multiple children of the wrong type.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ function TabLayout(props) {
}
class App extends React.Component {
render() {
return React.createElement(TabLayout, null, [
['Users', React.createElement("div", null)],
['Products', React.createElement("div", null)]
]);
return React.createElement(TabLayout, null,
[
['Users', React.createElement("div", null)],
['Products', React.createElement("div", null)]
]);
}
}
exports.App = App;
Loading
Loading