-
Notifications
You must be signed in to change notification settings - Fork 888
no-unused-variable: All imports unused #2577
Comments
I can't reproduce this in a sample project. Can you try getting an isolated repro? |
I am about to post a sample repo to github for this issue. |
Here is an example project that exercises the issue. |
Here's the problem: declare module '*'; TypeScript has an issue when using an imported type from this (presumably because no such type was ever declared). I've filed microsoft/TypeScript#15207. |
Hi andy, I removed that code and it still seems to be throwing "All imports are unused". Is there anything else that could be causing it? |
Are you getting:
Because that one (importing |
Right, I put that in there to show what goes wrong. There is one unused import, the other three however are used.
is a false statement. |
Would you prefer:
|
Interesting it looks like the wording was just changed between versions 3.15.1 and 5.1.0. in 3.15.1 it would throw this error instead
I believe this error now is fine it's just not as verbose. |
However this does break support for WebStorm. There is no longer linking in the results window. I shall open an issue with them. |
I'm having this issue too but can't isolate it: These are the first 7 lines of the offending file:
All imports are used, I tried removing all the imports and adding back only the ones used but it still complaining. On a different file I have My
|
@amatiasq Can't help without knowing the rest of the file. It may be another case of microsoft/TypeScript#14953. |
@andy-hanson I've finally isolated the issue and it's not easy to catch: https://gist.github.com/amatiasq/7352f52d9290311589e3df5bc2afc1fe Let me copy the readme description from the gist: Bug in TSLint
|
@amatiasq Fixed in |
@andy-hanson Are you sure? all imports in the gist are valid :\ |
The imports may not be valid from within the no-unused-variable rule's perspective because it uses a fake project. I tested it, tell me if you're able to reproduce it using the latest tslint and typescript. |
What do you mean with fake project? This started as a real project, I just removed the code than didn't make the bug disappear. Anyway with the last version of tslint it doesn't happen anymore. |
I'm referring to the implementation. |
I had the same issue when a type/interface was only used inside a generic (e.g. Upgrading to |
I'm running into the same issue using tslint 5.4.3 and tsc 2.4.1. |
I'm seeing a similar issue with a file containing only exports: export {foo} from './foo';
export {bar} from './bar'; Should not throw errors, but generates tsc --version = 3.1.3 |
@aneilbaboo @amatiasq I'm not able to reproduce these errors locally from the gist or what's posted in this thread. |
🤖 Beep boop! 👉 TSLint is deprecated 👈 and you should switch to typescript-eslint! 🤖 🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋 |
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Background:
Ionic 2 project
cli command:
tslint --type-check -c tslint.json --project tsconfig.json
Actual behavior
no-unused-variable reports All imports are unused.
example:
ERROR: src/providers/routes/MockRoutesFactory.ts[2, 1]: All imports are unused.
Expected behavior
No errors should be found for this file.
The text was updated successfully, but these errors were encountered: