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

tsd doesn't catch missing extensions in declaration files #191

Open
jedwards1211 opened this issue Apr 3, 2023 · 1 comment · May be fixed by #186
Open

tsd doesn't catch missing extensions in declaration files #191

jedwards1211 opened this issue Apr 3, 2023 · 1 comment · May be fixed by #186

Comments

@jedwards1211
Copy link

jedwards1211 commented Apr 3, 2023

Maybe this responsibility doesn't fall on tsd but I'm wondering if it should since I see Sindre Sorhus has a lot of projects that use it without any tsconfig, and tsd's defaults are getting kind of outdated since the ecosystem is moving to pure ESM.

In a package's .d.ts files for ESM modules, imports and export from statements with relative paths should have explicit file extensions. If not, then consumers will get errors if they use "moduleResolution": "nodenext".

But tsd doesn't catch problems like this. I tested it out by cloning sindresorhus/file-type, and changing the first line of index.d.ts to

- import type { FileTypeResult } from "./core.js";
+ import type { FileTypeResult } from "./core";

tsd still passes, but it should report an error. Errors from misconfigured pure ESM packages can be confusing, especially if using the default "skipLibCheck": true option. So it would reduce churn if tsd could report these errors by default.

It seems to me like tsd should check all ESM files with "moduleResolution": "nodenext" by default?

@sindresorhus
Copy link
Collaborator

Moving to ESM is worked on in #186.

@tommy-mitchell tommy-mitchell linked a pull request Apr 4, 2023 that will close this issue
6 tasks
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 a pull request may close this issue.

2 participants