check AssignmentPattern types - fixes babel/babel-eslint#184
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 },
|
||||
[ ]
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user