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

Type errors occur when used with browserslist-to-esbuild. #1111

Closed
odanado opened this issue Apr 26, 2024 · 0 comments · Fixed by #1118
Closed

Type errors occur when used with browserslist-to-esbuild. #1111

odanado opened this issue Apr 26, 2024 · 0 comments · Fixed by #1118

Comments

@odanado
Copy link
Contributor

odanado commented Apr 26, 2024

Defining the following tsup.config.ts will result in a type error.

import { defineConfig } from "tsup";
import browserslistToEsbuild from "browserslist-to-esbuild";

defineConfig({
    target: browserslistToEsbuild(),
})

error:

Type 'string[]' is not assignable to type 'Target | Target[] | undefined'.
  Type 'string[]' is not assignable to type 'Target[]'.
    Type 'string' is not assignable to type 'Target'.(2322)

ref: https://www.typescriptlang.org/play/?ssl=2&ssc=1&pln=3&pc=1#code/JYWwDg9gTgLgBAbzgEwKYDNgDtUGEJaYDmcAvnOlBCHAEQwDOArmLQNwBQokscARlQDuDVFAYAbYAxgAVCAFEGfJsHHIKVGrQERhoiVJgBaGBCOolKtew4c0mHPkLAiACgQc4XuDACGUIlQYAC5+IRExSWk5RWVVZFcASgAaDlJEjiA

This is due to tsup's use of the literal type Union.

export type Target = BrowserTarget | BrowserTargetWithVersion | EsTarget

Could adding (string & {}) to the type solve this problem?
microsoft/TypeScript#29729 (comment)

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
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.

1 participant