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

Flow import type counted as "defined but never used" #108

Closed
wincent opened this issue May 21, 2015 · 7 comments
Closed

Flow import type counted as "defined but never used" #108

wincent opened this issue May 21, 2015 · 7 comments
Labels

Comments

@wincent
Copy link

wincent commented May 21, 2015

import type Foo from 'foo';

function log(foo: Foo) {
  console.log(foo);
}

Complains that Foo is "defined but never used" (no-unused-vars).

PR #89 was previously submitted but withdrawn to address this, but the problem's still there. Filing this issue to make sure we don't lose track of it.

@wincent wincent changed the title Flow import type Flow import type counted as "defined but never used" May 21, 2015
@hzoo hzoo added the escope label May 21, 2015
@hzoo
Copy link
Member

hzoo commented May 21, 2015

Ok thanks!. So I think I know how to fix this - do the same escope patching as for decorators.


However there's some more places where flow types are used that could result in the same error right? We probably want to cover all of those as well?

function log(foo): Foo { return 1; } // return
var foo: Foo = 1; // var decl

I'l probably need to use the tests in https://github.com/babel/babel/blob/088846a3479375a51d71084cb4fd70ef8fa21d29/test/acorn/tests-flow.js then? Looks like a lot of places!

hzoo added a commit to hzoo/babel-eslint that referenced this issue May 21, 2015
hzoo added a commit to hzoo/babel-eslint that referenced this issue May 21, 2015
@hzoo
Copy link
Member

hzoo commented May 21, 2015

@wincent I think #109 should fix a lot of the flow type unused issues? There's a lot missing but it probably covers most use cases.

hzoo added a commit to hzoo/babel-eslint that referenced this issue May 22, 2015
@hzoo hzoo closed this as completed in a399282 Jun 2, 2015
hzoo added a commit that referenced this issue Jun 2, 2015
visit flow types - fixes #108
@wincent
Copy link
Author

wincent commented Jun 2, 2015

Thanks @hzoo!

wincent added a commit to wincent/corpus that referenced this issue Jun 2, 2015
I was hoping this would fix these lint errors:

```
/Users/glh/code/corpus/src/app/OperationsQueue.js
  8:12  error  Promise is defined but never used  no-unused-vars

/Users/glh/code/corpus/src/app/Repo.js
  10:12  error  Promise is defined but never used  no-unused-vars
```

For reference, the usage sites look like this:

```
import type Promise from 'bluebird';

type Operation = () => Promise;
```

Alas, babel/babel-eslint#108 doesn't fix this
particular case, although it does help with others (see the tests in the
attached commit on that PR).
@FDiskas
Copy link

FDiskas commented Feb 12, 2018

Still got this error 💊

import type { TDemo } from '../typings/demo';

@smikheiev
Copy link

I also had the same problem with version 8.2.1:
import type { $Application, $Request, $Response } from 'express'
The only thing that helped was rollback to version 7.2.1.

@shengt
Copy link

shengt commented Feb 18, 2018

Same issue here. 8.0.3 is fine

import type {Request, Response} from '../types'

@1215904405a
Copy link

flow react warning type 'Props' is defined but never used no-unused-vars how handle?

nicolo-ribaudo pushed a commit to babel/babel that referenced this issue Nov 14, 2019
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

6 participants