Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Interface produces no-undef errors #437

Closed
nickserv opened this issue Jan 26, 2018 · 8 comments · Fixed by #540
Closed

Interface produces no-undef errors #437

nickserv opened this issue Jan 26, 2018 · 8 comments · Fixed by #540

Comments

@nickserv
Copy link

What version of TypeScript are you using?
2.6.2

What version of typescript-eslint-parser are you using?
12.0.0

What code were you trying to parse?

interface Runnable {
  run (): Result
  toString (): string
}

What did you expect to happen?
Pass with no errors.

What happened?

> eslint **/*.{j,t}s


/Users/nick/Repos/purespec/matchers/Runnable.ts
  1:11  error  'Runnable' is not defined  no-undef
  2:3   error  'run' is not defined       no-undef
  2:11  error  'Result' is not defined    no-undef

✖ 3 problems (3 errors, 0 warnings)
@bondom
Copy link

bondom commented Mar 29, 2018

Is there workaround for this problem?

@EdGraVill
Copy link

This is resolved in #75

@Bessonov
Copy link

Bessonov commented Jun 8, 2018

Unfortunately, #75 isn't resolution.

@JamesHenry
Copy link
Member

A custom rule will need to be created in the plugin to handle this. It would be fantastic if one of the people affected by this issue could contribute to it.

@jacob-israel-turner
Copy link

Has there been any effort on this? If not, I'd be willing to take a stab - although I have very little experience writing linting rules. Is there somewhere I could look for a good first step?

@amcdnl
Copy link

amcdnl commented Aug 29, 2018

Any updates on this? With the new Babel7 TypeScript support this becomes more interesting.

@itsdouges
Copy link

Alternatively you could disable the rule and just use ts compiler settings to error on unused variables?

https://www.typescriptlang.org/docs/handbook/compiler-options.html

--noUnusedLocals --noUnusedParameters

@cooperka
Copy link

cooperka commented Nov 2, 2018

See comments on similar issue #416 for a few workarounds.

Namely, you can safely disable no-undef for .ts files because TypeScript will fail to compile with undefined vars. The rule is redundant. Full example here: #416 (comment)

module.exports = {
  rules: {
    // ... your js rules ...
  },

  overrides: {
    files: ['**/*.ts'],
    parser: 'typescript-eslint-parser',
    rules: {
      'no-undef': 'off'
    }
  }
}

mysticatea added a commit that referenced this issue Nov 8, 2018
mysticatea added a commit that referenced this issue Nov 13, 2018
* Update: add proper scope analysis (fixes #535)

* add computed-properties-in-type fixture

* add computed-properties-in-interface fixture

* add function-overload fixture

* add method-overload fixture

* add class-properties fixture

* add decorators fixture

* update visitor-keys

* add declare-global fixture

* fix typo

* add test for typeof in array destructuring

* add namespace fixture

* add declare-module fixture

* fix crash

* add declare-function.ts fixture

* add abstract-class fixture

* add typeof-in-call-signature fixture

* add test for #416

* add test for #435

* add test for #437

* add test for #443

* add test for #459

* add test for #466

* add test for #471

* add test for #487

* add test for #535

* add test for #536

* add test for #476

* fix test to use `expect()`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants