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

"declare global" prevents accessing parent scope (no-undef) #21

Closed
JamesHenry opened this issue Jan 15, 2019 · 3 comments
Closed

"declare global" prevents accessing parent scope (no-undef) #21

JamesHenry opened this issue Jan 15, 2019 · 3 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

@JamesHenry
Copy link
Member

This issue was initially reported here: eslint/typescript-eslint-parser#579


What version of TypeScript are you using?
3.1.3

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

What code were you trying to parse?

import React from 'react';

declare global {
  interface Global {
    __r: typeof React;
  }
}

// To complement `global.__r = React;`

What did you expect to happen?
No lint errors

What happened?

6:18 error 'React' is not defined no-undef

typescript-eslint-parser/analyze-scope.js:Referencer.visitGlobalAugmentation seems to replace the current scope with the global one, which makes accessing React in the above example
incorrectly say it's not defined.

@mysticatea (via #540): what case does visitGlobalAugmentation solve?

JamesHenry pushed a commit that referenced this issue Jan 17, 2019
JamesHenry pushed a commit that referenced this issue Jan 17, 2019
JamesHenry pushed a commit that referenced this issue Jan 18, 2019
@JamesHenry JamesHenry added the package: parser Issues related to @typescript-eslint/parser label Jan 18, 2019
@bradzacher bradzacher added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin migration-test and removed package: parser Issues related to @typescript-eslint/parser labels Jan 18, 2019
@bradzacher bradzacher added the scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser label Apr 15, 2019
@ifiokjr
Copy link
Contributor

ifiokjr commented Sep 24, 2019

@JamesHenry I'm running into the same error. It only happens a few times in my codebase so it's easy enough to ignore, but I'm wondering if there's a workaround or if there are any plans to update the rule.

@bradzacher
Copy link
Member

Recommendation is to turn off the rule, as the typescript compiler itself should handle everything that the rule covers.

Otherwise - no plans right now. It involves adding scope analysis support, which is a huge piece of work none of the core maintainers have time to work on right now.

@bradzacher
Copy link
Member

Merging into #1856

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2020
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

4 participants