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

import/no-unresolved when trying to import types from @types/* #17

Closed
manuelbieh opened this issue Apr 30, 2019 · 5 comments · Fixed by #27
Closed

import/no-unresolved when trying to import types from @types/* #17

manuelbieh opened this issue Apr 30, 2019 · 5 comments · Fixed by #27

Comments

@manuelbieh
Copy link

manuelbieh commented Apr 30, 2019

I'm trying to use eslint with @typescript-eslint/parser and eslint-plugin-import but no matter what I do, I get an error:

Unable to resolve path to module 'express-serve-static-core'  import/no-unresolved

whenever I try to import types from @types packages.

Looks like the sourceType: 'module' parserOption is causing this error but when I remove it I get another error:

Parsing error: ImportDeclaration should appear when the mode is ES6 and in the module context

I created a minimal example to reproduce this error. Probably it's just a setting that's wrong but I have tried different settings, plugins, parserOptions and what not and I just don't get it working:
https://github.com/manuelbieh/eslint-typescript-import-bug

So I'm not sure if the problem is on my side or if it is a bug in this package.

@benmosher
Copy link
Member

benmosher commented May 1, 2019

Ah, sweet, you beat me to this. was going to open a similar issue and link to import-js/eslint-plugin-import#1341 (comment)

FWIW I'd call this an enhancement request and not a bug. But I am relatively new to the TS ecosystem so maybe there's an argument for calling this a bug.

Either way, I think it'd be straightforward to try a resolution against @types/{whatever} if no *.{ts,tsx,d.ts} files are found at {whatever}.

benmosher added a commit to benmosher/eslint-import-resolver-typescript that referenced this issue May 1, 2019
@JounQin
Copy link
Collaborator

JounQin commented Jun 30, 2019

For anything maybe interested, you can try eslint-import-resolver-typescript@JounQin/node_modules#eslint-import-resolver-typescript temporarily (PR made at #20).

@JounQin
Copy link
Collaborator

JounQin commented Sep 27, 2019

@JounQin JounQin mentioned this issue Sep 28, 2019
@femmor
Copy link

femmor commented Jun 9, 2023

Try https://github.com/rx-ts/eslint-import-resolver-ts instead.

This worked for me. Thanks

@JounQin
Copy link
Collaborator

JounQin commented Jun 9, 2023

@femmor This should be unnecessary, that plugin has been merged into this upstream project already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants