csstype icon indicating copy to clipboard operation
csstype copied to clipboard

eslint import/no-unresolved error for csstype

Open nishantnaagnihotri opened this issue 3 years ago • 4 comments

Eslint raises compilation error of the rule import/no-unresolved, for the csstype import statement.

This is because the package.json of csstype has a blank value for "main" field. It should have the value as "index.d.ts".

I did the change locally and eslint stopped complaining.

nishantnaagnihotri avatar Sep 23 '21 12:09 nishantnaagnihotri

The main field is the same as @types packages which is just "". There could be other issues when adding a .d.ts file to main so I'd say it's better to keep it like this even though @types are used differently. But maybe this will do the trick for you?

import type * as CSS from 'csstype';

frenic avatar Sep 23 '21 12:09 frenic

Thanks for the prompt response!!

I tried it out, the error does not go away :disappointed:

nishantnaagnihotri avatar Sep 23 '21 13:09 nishantnaagnihotri

Maybe the answer to your issue can be found here https://github.com/import-js/eslint-plugin-import/issues/1341?

frenic avatar Sep 23 '21 13:09 frenic

They suggest to use eslint-import-resolver-typescript and yes, I can confirm that (at least for me) it does the trick. Thanks for pointing this out.

tobiaswaltl avatar Oct 12 '21 12:10 tobiaswaltl