Skip to content

Commit dfaff04

Browse files
authored
Fix flow type spread handling (babel#465)
1 parent f59d200 commit dfaff04

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function monkeypatch(modules) {
107107
// loops
108108
callProperties: { type: "loop", values: ["value"] },
109109
indexers: { type: "loop", values: ["key", "value"] },
110-
properties: { type: "loop", values: ["value"] },
110+
properties: { type: "loop", values: ["argument", "value"] },
111111
types: { type: "loop" },
112112
params: { type: "loop" },
113113
// single property
@@ -142,7 +142,10 @@ function monkeypatch(modules) {
142142
for (var j = 0; j < nodeProperty.length; j++) {
143143
if (Array.isArray(propertyType.values)) {
144144
for (var k = 0; k < propertyType.values.length; k++) {
145-
checkIdentifierOrVisit.call(this, nodeProperty[j][propertyType.values[k]]);
145+
var loopPropertyNode = nodeProperty[j][propertyType.values[k]];
146+
if (loopPropertyNode) {
147+
checkIdentifierOrVisit.call(this, loopPropertyNode);
148+
}
146149
}
147150
} else {
148151
checkIdentifierOrVisit.call(this, nodeProperty[j]);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"babel-code-frame": "^6.22.0",
1616
"babel-traverse": "^6.23.1",
1717
"babel-types": "^6.23.0",
18-
"babylon": "^6.16.1"
18+
"babylon": "^6.17.0"
1919
},
2020
"scripts": {
2121
"test": "npm run lint && npm run test-only",

test/non-regression.js

+12
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,18 @@ describe("verify", () => {
574574
);
575575
});
576576

577+
it("supports type spreading", () => {
578+
verifyAndAssertMessages(
579+
unpad(`
580+
type U = {};
581+
type T = {a: number, ...U, ...V};
582+
`),
583+
{ "no-undef": 1, "no-unused-vars": 1 },
584+
[ "2:6 'T' is defined but never used. no-unused-vars",
585+
"2:31 'V' is not defined. no-undef" ]
586+
);
587+
});
588+
577589
it("1", () => {
578590
verifyAndAssertMessages(
579591
unpad(`

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ babel-types@^6.15.0, babel-types@^6.23.0:
113113
lodash "^4.2.0"
114114
to-fast-properties "^1.0.1"
115115

116-
babylon@^6.13.0, babylon@^6.15.0, babylon@^6.16.1:
117-
version "6.16.1"
118-
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3"
116+
babylon@^6.13.0, babylon@^6.15.0, babylon@^6.17.0:
117+
version "6.17.0"
118+
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932"
119119

120120
balanced-match@^0.4.1:
121121
version "0.4.2"

0 commit comments

Comments
 (0)