Skip to content

[Feature]: Add jsExtension for dts #263

@Timeless0911

Description

@Timeless0911

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions