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

Reports Flow types for function parameters with default values as unused. #184

Closed
lemonmade opened this issue Sep 17, 2015 · 5 comments
Closed
Labels

Comments

@lemonmade
Copy link

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.

@hzoo
Copy link
Member

hzoo commented Sep 17, 2015

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 {}) #132

@hzoo
Copy link
Member

hzoo commented Sep 17, 2015

Ok I guess it's a bug since options: ResolveOptionType by itself works.

@hzoo
Copy link
Member

hzoo commented Sep 17, 2015

However a workaround is to do options = {} : ResolveOptionType instead of options : ResolveOptionType = {}.

@hzoo hzoo closed this as completed in 53e0664 Sep 17, 2015
@hzoo
Copy link
Member

hzoo commented Sep 17, 2015

Ok I fixed it as well.

@lemonmade
Copy link
Author

Fabulous, thank you very much. The proposed workaround throws an error in Flow, so the solution is great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants