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

[Feature]: Add jsExtension for dts #263

Open
Timeless0911 opened this issue Oct 9, 2024 · 0 comments
Open

[Feature]: Add jsExtension for dts #263

Timeless0911 opened this issue Oct 9, 2024 · 0 comments

Comments

@Timeless0911
Copy link
Collaborator

Timeless0911 commented Oct 9, 2024

Details

input

// src/index.ts
export { appLoader, type AppLoaderType as AppLoader } from "./core/loader";

output

// dist/esm/index.d.mts
export { appLoader, type AppLoaderType as AppLoader } from "./core/loader";

There exists an error Module './core/loader' or its corresponding type declaration could not be found.ts(2307) in output, so the esm types is incorrect for use.

We should add js extension in .d.ts / .d.cts / .d.mts file to make resolution work as what tsup do when using bundleless DTS.
bundle DTS should not do this since api-extractor can not deal dts file like that.

// dist/esm/index.d.mts
export { appLoader, type AppLoaderType as AppLoader } from "./core/loader.mjs";

references:

  1. https://www.typescriptlang.org/docs/handbook/modules/theory.html#the-role-of-declaration-files
  2. What rollup-plugin-dts do
  3. https://www.typescriptlang.org/tsconfig/#moduleResolution
  4. Typescript 5.7 -- Path Rewriting for Relative Paths
@Timeless0911 Timeless0911 added the 🐞 bug Something isn't working label Oct 9, 2024
@Timeless0911 Timeless0911 changed the title [Bug]: Should add jsExtension for .d.mts [Bug]: Should add jsExtension for dts Oct 22, 2024
@Timeless0911 Timeless0911 changed the title [Bug]: Should add jsExtension for dts [Feature]: Should add jsExtension for dts Oct 22, 2024
@Timeless0911 Timeless0911 added 💡 feature and removed 🐞 bug Something isn't working labels Oct 22, 2024
@Timeless0911 Timeless0911 changed the title [Feature]: Should add jsExtension for dts [Feature]: Add jsExtension for dts Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant