Skip to content
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

[no-undef] False positive for Interfaces #342

Closed
dawsonc623 opened this issue Mar 9, 2019 · 5 comments
Closed

[no-undef] False positive for Interfaces #342

dawsonc623 opened this issue Mar 9, 2019 · 5 comments
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser

Comments

@dawsonc623
Copy link

Repro

Paste the below code into a file and lint it.

interface StringCollection
{
  get(
    index : number
  ) : string;
}

export default StringCollection;

Expected Result

ESLint should not produce any errors

Actual Result

ESLint produces a no-undef error.

Additional Info

Oddly, it also complains about me using new Map<T, U>() with the same rule. I am not sure if it is the same root cause, but I figured it was worth noting.

Versions

package version
@typescript-eslint/eslint-plugin 1.4.2
@typescript-eslint/parser 1.4.2
TypeScript 3.3.3333
ESLint 5.15.1
node 8.15.0
npm* 6.4.1
yarn* 1.12.3

* I use Yarn instead of NPM

@dawsonc623 dawsonc623 added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 9, 2019
@bradzacher bradzacher added the bug Something isn't working label Mar 10, 2019
buschtoens pushed a commit to ClarkSource/eslint-config that referenced this issue Mar 29, 2019
Temporary disabling this rule for `.ts` files because, it throws an error for exporting interfaces, and we can safely disable it since TypeScript will fail to compile with undefined vars, more info:
* typescript-eslint/typescript-eslint#342
* eslint/typescript-eslint-parser#437 (comment)
@bradzacher bradzacher removed the triage Waiting for maintainers to take a look label Apr 11, 2019
@edsrzf
Copy link
Contributor

edsrzf commented Apr 18, 2019

Slightly more minimal repro case:

interface I {}
export default I

Non-default exports also trigger it:

interface I {}
export { I }

Type aliases are affected too:

type T = {}
export default T

I'm going to try to figure this out because it's affecting me, but don't really know what I'm doing so any help's appreciated.

@bradzacher bradzacher added the scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser label Apr 19, 2019
@bradzacher
Copy link
Member

We've got plans to fix the scope analysis, but it's a big job because of the complexities that the type system introduces, so there's no ETA on that.

A workaround is to not use the no-undef rule with typescript code - the tsc will catch these sorts of bugs for you, so you don't really need the rule on.

@abdonrd
Copy link

abdonrd commented Aug 14, 2019

Any news here? Thanks in advance!

@linonetwo
Copy link

Just disable it eslint/typescript-eslint-parser#437

@bradzacher bradzacher added this to the scope analysis rewrite milestone Apr 6, 2020
@bradzacher
Copy link
Member

Merging into #1856

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser
Projects
None yet
Development

No branches or pull requests

5 participants