Skip to content

Commit

Permalink
fix: fix error with other cases (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
HsuTing authored and gajus committed Jun 13, 2019
1 parent e8d640c commit dd10c3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rules/useFlowType.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ const create = (context) => {
TypeParameterDeclaration (node) {
node.params.forEach((param) => {
if (param.default && param.default.typeParameters) {
if (param.default.type === 'GenericTypeAnnotation') {
markTypeAsUsedWithGenericType(param.default);
}

param.default.typeParameters.params.forEach((typeParameterNode) => {
markTypeAsUsedWithGenericType(typeParameterNode);
if (typeParameterNode.type === 'GenericTypeAnnotation') {
markTypeAsUsedWithGenericType(typeParameterNode);
}
});
}
});
Expand Down
6 changes: 6 additions & 0 deletions tests/rules/assertions/useFlowType.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const VALID_WITH_USE_FLOW_TYPE = [
errors: [
'\'A\' is defined but never used.'
]
},
{
code: 'import type A from "a"; type X<B = A<string>> = { b: B }; let x: X; console.log(x);',
errors: [
'\'A\' is defined but never used.'
]
}
];

Expand Down

0 comments on commit dd10c3f

Please sign in to comment.