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

fix(types): add explicit extension for ESM compatibility #1417

Merged
merged 1 commit into from Jun 3, 2022

Conversation

jgoux
Copy link
Contributor

@jgoux jgoux commented Jun 3, 2022

Hello 👋

When consuming vitest/config from my own project which is using ESM ("type": "module"), defineConfig is seen as any.

I think this is because vitest is itself using ESM, so the types definition files have to use explicit paths when importing/exporting local files.

I think the issue was never detected before because the types definition files outside of config.d.ts and node.d.ts are all flattened and don't import/export local files.

I already encountered this issue here: tinyhttp/tinyhttp#359

What's a bit strange in your case is that TypeScript seems to see the types, but @typescript-eslint can't (it relies in TypeScript itself for types resolution 🤔):

image

Anyway, I think if you are declaring your module as ESM and you are writing it in TypeScript, it's a best practice (or even a requirement?) to use explicit paths in the import/export statements for local files.

@netlify
Copy link

netlify bot commented Jun 3, 2022

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 114f4e3
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/6299e2516ad381000734f80f
😎 Deploy Preview https://deploy-preview-1417--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@antfu antfu merged commit 4b54aed into vitest-dev:main Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants