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)
Defining the following
tsup.config.ts
will result in a type error.error:
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. https://github.com/egoist/tsup/blob/00188a0dc848c48fac45de245d1e021f370a84a3/src/options.ts#L88
Could adding
(string & {})
to the type solve this problem? https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939Upvote & Fund