egoist / egoist/tsup

Multiple options configuration warns about type error TS2345

Open
#866 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

I have npm package which both can be imported in other projects and also be used as a CLI. To do this, I have 2 option configurations:

```ts
export default defineConfig(() => [
{
entry: {
lib: './src/index.ts',
},
},
{
entry: {
cli: './src/cli.ts',
},
},
]);
```

However, this warns about the TS2345 error. Basically, it is expecting both the `entry` objects to have same keys. Since I added `lib` in first one, it is expecting that I add it to the second one as well and same for `cli`.

If I add a `@ts-ignore` comment, `tsup` works as expected and generates the desired outputs.

Also, creating the options object outside of the array fixes the issue:

```ts
const op1: Options = {
entry: {
lib: './src/index.ts',
},
}

const op2: Options = {
entry: {
cli: './src/cli.ts',
},
}

export default defineConfig(() => [
op1,
op2,
]);
```

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.