egoist / egoist/tsup

dts resolve is not working (with repro)

Open
#1,007 9 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

I cannot get the `dts.resolve` option to work at all.

All of the options I have tried thus far result in importing of the types from an external package.

Things I have done:

- [x] Imported the dependency as a `devDependencies`
- [x] Used the imported types and also re-exported them from the package.
- [x] Set `dts.resolve` to `true`
- [x] Tried setting `dts.resolve` to an array and include the specific package.
- [x] Tried adding `noExternal` with the package name to force it to always bundle.

Repro repo: https://github.com/moltar/tsup-dts-resolve#readme

---

**Edit:** Interesting, 🤔 ...

This seems to be limited to the specific package (`@changesets/types`).

I tried to make the same example by importing `tsup` type `Format` and it actually worked, and re-exported the `Format` type as required.

```ts
// test
type Format = 'cjs' | 'esm' | 'iife';

type MyFormat = Format;
declare const config: MyFormat;

export { MyFormat, config };
```

---

**Edit 2**: That does appear to be an issue with the package!

Adding this to `@changesets/types` `package.json` file does fix the problem:

```json
"types": "dist/types.cjs.d.ts",
```

Output:

```ts
// test
declare const DEPENDENCY_TYPES: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
declare type DependencyType = typeof DEPENDENCY_TYPES[number];

type MyDependencyType = DependencyType;
declare const config: MyDependencyType;

export { MyDependencyType, config };
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.