When using Flow, most type annotations work perfectly. However, a custom type that is only used as a type declaration for a function parameter with a default value is reported as being unused. Here's a simple example:
type ResolveOptionType = {
depth?: number,
identifier?: string
};
function resolve(
root: Object,
options: ResolveOptionType = {}
): Object { /* ... */ }
Reports the following error: error "ResolveOptionType" is defined but never used no-unused-vars. If this is a limitation of Flow, not babel-eslint, please let me know so I can put my issue in the right place.
Pretty sure it's not a limitation of flow.
It might be similar to an known issue I put in the readme? Have to look into it more
no-unused-vars/no-undef with Flow declarations (declare module A {}) #132Ok I guess it's a bug since options: ResolveOptionType by itself works.
However a workaround is to do options = {} : ResolveOptionType instead of options : ResolveOptionType = {}.
Ok I fixed it as well.
Fabulous, thank you very much. The proposed workaround throws an error in Flow, so the solution is great!
Most helpful comment
Ok I fixed it as well.