Skip to content
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

Try out render types #58

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = (context, options = {}) => {
];

let plugins = [
'babel-plugin-syntax-hermes-parser',
'@babel/plugin-transform-flow-strip-types', // 2
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
Expand Down
47 changes: 45 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-flow": "^7.24.0",
"@babel/preset-react": "^7.23.3"
"@babel/preset-react": "^7.23.3",
"babel-plugin-syntax-hermes-parser": "^0.20.1"
},
"devDependencies": {
"@babel/core": "^7.24.0",
Expand Down
12 changes: 12 additions & 0 deletions test/__file_snapshots__/cjsm--Flow-render-types-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

function Foo() {
return /*#__PURE__*/React.createElement("div", null);
}
function Bar() {
return /*#__PURE__*/React.createElement(Foo, null);
}
function Baz(_ref) {
var foo = _ref.foo;
/*#__PURE__*/React.createElement("div", null, foo);
}
5 changes: 2 additions & 3 deletions test/__file_snapshots__/cjsm--optional-chaining-0
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ var obj = {
}
}
};
var baz = obj === null || obj === void 0 || (_obj$foo = obj.foo) === null || _obj$foo === void 0 || (_obj$foo = _obj$foo.bar) === null || _obj$foo === void 0 ? void 0 : _obj$foo.baz; // 42

var safe = obj === null || obj === void 0 || (_obj$qux = obj.qux) === null || _obj$qux === void 0 ? void 0 : _obj$qux.baz; // undefined
var baz = obj === null || obj === void 0 || (_obj$foo = obj.foo) === null || _obj$foo === void 0 || (_obj$foo = _obj$foo.bar) === null || _obj$foo === void 0 ? void 0 : _obj$foo.baz;
var safe = obj === null || obj === void 0 || (_obj$qux = obj.qux) === null || _obj$qux === void 0 ? void 0 : _obj$qux.baz;
10 changes: 10 additions & 0 deletions test/__file_snapshots__/esm--Flow-render-types-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function Foo() {
return /*#__PURE__*/React.createElement("div", null);
}
function Bar() {
return /*#__PURE__*/React.createElement(Foo, null);
}
function Baz(_ref) {
var foo = _ref.foo;
/*#__PURE__*/React.createElement("div", null, foo);
}
5 changes: 2 additions & 3 deletions test/__file_snapshots__/esm--optional-chaining-0
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ var obj = {
}
}
};
var baz = obj === null || obj === void 0 || (_obj$foo = obj.foo) === null || _obj$foo === void 0 || (_obj$foo = _obj$foo.bar) === null || _obj$foo === void 0 ? void 0 : _obj$foo.baz; // 42

var safe = obj === null || obj === void 0 || (_obj$qux = obj.qux) === null || _obj$qux === void 0 ? void 0 : _obj$qux.baz; // undefined
var baz = obj === null || obj === void 0 || (_obj$foo = obj.foo) === null || _obj$foo === void 0 || (_obj$foo = _obj$foo.bar) === null || _obj$foo === void 0 ? void 0 : _obj$foo.baz;
var safe = obj === null || obj === void 0 || (_obj$qux = obj.qux) === null || _obj$qux === void 0 ? void 0 : _obj$qux.baz;
11 changes: 11 additions & 0 deletions test/__file_snapshots__/esmodules--Flow-render-types-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function Foo() {
return /*#__PURE__*/React.createElement("div", null);
}
function Bar() {
return /*#__PURE__*/React.createElement(Foo, null);
}
function Baz({
foo
}) {
/*#__PURE__*/React.createElement("div", null, foo);
}
5 changes: 2 additions & 3 deletions test/__file_snapshots__/esmodules--optional-chaining-0
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ let obj = {
}
}
};
let baz = obj === null || obj === void 0 || (_obj$foo = obj.foo) === null || _obj$foo === void 0 || (_obj$foo = _obj$foo.bar) === null || _obj$foo === void 0 ? void 0 : _obj$foo.baz; // 42

let safe = obj === null || obj === void 0 || (_obj$qux = obj.qux) === null || _obj$qux === void 0 ? void 0 : _obj$qux.baz; // undefined
let baz = obj === null || obj === void 0 || (_obj$foo = obj.foo) === null || _obj$foo === void 0 || (_obj$foo = _obj$foo.bar) === null || _obj$foo === void 0 ? void 0 : _obj$foo.baz;
let safe = obj === null || obj === void 0 || (_obj$qux = obj.qux) === null || _obj$qux === void 0 ? void 0 : _obj$qux.baz;
13 changes: 13 additions & 0 deletions test/__file_snapshots__/node--Flow-render-types-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";

function Foo() {
return /*#__PURE__*/React.createElement("div", null);
}
function Bar() {
return /*#__PURE__*/React.createElement(Foo, null);
}
function Baz({
foo
}) {
/*#__PURE__*/React.createElement("div", null, foo);
}
5 changes: 2 additions & 3 deletions test/__file_snapshots__/node--optional-chaining-0
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ let obj = {
}
}
};
let baz = obj?.foo?.bar?.baz; // 42

let safe = obj?.qux?.baz; // undefined
let baz = obj?.foo?.bar?.baz;
let safe = obj?.qux?.baz;
8 changes: 8 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ let cases = [
[1, 2].flatMap(x => [x * 2])
`,
],
[
'Flow render types',
`
component Foo() { return <div /> }
component Bar() renders Foo { return <Foo /> }
component Baz(foo: renders Foo) { <div>{foo}</div> }
`,
],
];

test.each(cases)('cjsm: %s', (name, input) => {
Expand Down
Loading