-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[no-unused-vars] False positive for "export import Namespace" #4129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Why aren't you just exporting the thing directly? Like so export namespace Foo {
export { Bar };
} Does this not work? I'll be honest when I say that I didn't even know what you had written was valid TS syntax. I'm actually really surprised to see that TS lets you directly export an import. |
Unfortunately, I haven't found a way to just use something like The (Tbh, I didn't know all of this until yesterday :D) I was assuming that any kind of |
No - it's just that the "import equals" syntax is so, so, so rarely used that nobody runs into this. You'll find that most rules won't even consider it because nobody uses it any more. It used to be used a whole lot more to interop with commonjs, but the Namespaces themselves are pretty rarely used now-a-days as well as people just use module syntax to handle things - in a lot of codebases there's little need to use namespaces to group things with a module and just grouping at the module level is more than enough. TL;DR - It's just a combination of "things most people don't use". |
I was surprised why nobody had yet reported this problem, but I guess that namespaces are indeed pretty rarely used nowadays. Thank you that you had a look into this! Until #4130 gets resolved, I will just disable the reported error in my code. (And eventually, maybe I will find a way to migrate to modules 😄) |
typescript-eslint/typescript-eslint#4129 False positive from `@typescript-eslint`
Repro
TSConfig:
Expected Result
I expected no "no-unused-vars" error on
TheBar
, since I am exporting bothFoo
andTheBar
.Actual Result
On
TheBar
, I am getting the error'TheBar'
is defined but never used`Additional Info
I am not familiar with the
--debug
output, but I cannot really see anything that could point to the reason of the problem. Still, this is the debug output, maybe it helps:Versions
@typescript-eslint/eslint-plugin
5.3.1
@typescript-eslint/parser
5.3.1
TypeScript
4.4.4
ESLint
8.2.0
node
16.13.0
The text was updated successfully, but these errors were encountered: