Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
check AssignmentPattern types - fixes #184
Browse files Browse the repository at this point in the history
  • Loading branch information
hzoo committed Sep 17, 2015
1 parent 873c973 commit 53e0664
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,13 @@ function monkeypatch() {
// only visit if function parameters have types
if (node.params) {
for (var i = 0; i < node.params.length; i++) {
if (node.params[i].typeAnnotation) {
checkIdentifierOrVisit.call(this, node.params[i]);
var param = node.params[i];
if (param.typeAnnotation) {
checkIdentifierOrVisit.call(this, param);
} else if (t.isAssignmentPattern(param)) {
if (param.left.typeAnnotation) {
checkIdentifierOrVisit.call(this, param.left);
}
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions test/non-regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -1309,4 +1309,23 @@ describe("verify", function () {
[ ]
)
});

it("default param flow type no-unused-vars #184", function () {
verifyAndAssertMessages(
[
"type ResolveOptionType = {",
"depth?: number,",
"identifier?: string",
"};",
"",
"export default function resolve(",
"options: ResolveOptionType = {}",
"): Object {",
"options;",
"}",
].join("\n"),
{ "no-unused-vars": 1, "no-undef": 1 },
[ ]
)
});
});

0 comments on commit 53e0664

Please sign in to comment.