check AssignmentPattern types - fixes babel/babel-eslint#184

This commit is contained in:
Henry Zhu
2015-09-17 09:42:18 -04:00
parent 6dc026c203
commit b5e0dbe8e8
2 changed files with 26 additions and 2 deletions

View File

@@ -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);
}
}
}
}

View File

@@ -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 },
[ ]
)
});
});