eslint-types / eslint-define-config

Provide a defineConfig function for .eslintrc.js files
MIT License
361 stars 26 forks source link

Can't import types #207

Closed burtek closed 1 year ago

burtek commented 1 year ago

After #204 was merged and released in 1.21.0, I can't do any type imports, i.e:

import type { FlatESLintConfigItem } from 'eslint-define-config';

image image1

Works correctly for 1.20.0

Shinigami92 commented 1 year ago

You can push this forward by forking and try to create a bugfix PR Otherwise you need to wait some days until I'm back in "working-mode" I'm currently enjoying the last days of my vacation and grind Diablo 4 😅

burtek commented 1 year ago

@Shinigami92 happy to take a look tomorrow evening once I'm back from in-laws 😅

Shinigami92 commented 1 year ago

I now had the first time after vacation to test your issue and somehow I cannot reproduce your problem 🤔

burtek commented 1 year ago

@Shinigami92 what TS version were you testing this on?

Tried playing with it (both changing TS version, my configuration and your package.json) and can't figure out what's wrong with it...

burtek commented 1 year ago

When a file is considered an ES module, a few different rules come into play compared to CommonJS:

  • relative import paths need full extensions (e.g we have to write import "./foo.js" instead of import "./foo")

https://www.typescriptlang.org/docs/handbook/esm-node.html#type-in-packagejson-and-new-extensions

It started working correctly for me when I changed your .d.ts files to contain extensions. I think that's the issue here. But still interested of your setup, since you're saying it works for you as is?

Shinigami92 commented 1 year ago

I have just a normal TypeScript esm project

I'm sorry I have not the time to debug your problems if you cannot provide a minimal reproducible

Also it starts to sound like it's a problem with your tsconfig or whatever

So I think I will close this issue for now Feel free to reopen when you provide a minimal reproducible

burtek commented 1 year ago

FFR the issue is that my project was set to have module resolution "Node16" while eslint-define-config is "Node" (a.k.a. "Node10") and those two don't play well.