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

eslint(no-undef) doesn’t understand TypeScript generics #2093

Closed
drwpow opened this issue Jan 19, 2024 · 3 comments · Fixed by #5580
Closed

eslint(no-undef) doesn’t understand TypeScript generics #2093

drwpow opened this issue Jan 19, 2024 · 3 comments · Fixed by #5580
Assignees
Labels
A-linter Area - Linter good first issue Experience Level - Good for newcomers

Comments

@drwpow
Copy link

drwpow commented Jan 19, 2024

Given the following TypeScript code, it throws an error:

 eslint(no-undef): Disallow the use of undeclared variables
function resolve<T>(path: string): T {
  return { path } as T;            
}

help: 'T' is not defined.

I understand this may just be a conflict between enabled rules; if so, maybe just adding a note in doc about recommended TS settings?


Also as a similar-but-slightly-different error, what’s the recommended way to handle builtin libraries?

 eslint(no-undef): Disallow the use of undeclared variables

const root = new URL("../", import.meta.url);
                 ───
help: 'URL' is not defined.

I understand throwing an error for “magically-loaded” globals like test runner expect() calls. But for built-in DOM libraries, is there a recommended setup to allow this?


For both, I realize it may just require documentation, but wanted to ask for my own understanding. Thanks for such an amazing project!

@mysteryven

This comment was marked as outdated.

@Dunqing

This comment was marked as outdated.

@Boshen Boshen added good first issue Experience Level - Good for newcomers A-linter Area - Linter labels Aug 18, 2024
@Boshen
Copy link
Member

Boshen commented Aug 18, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter good first issue Experience Level - Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants