How to export typings from a node package #935
Replies: 3 comments 5 replies
-
I'm facing a similar issue. I'm bundling a third-party package that contains a file with several enums, each prefixed with the export keyword. However, after the bundling process is complete, all the enums are missing the export keyword. |
Beta Was this translation helpful? Give feedback.
-
Any solution for this yet? My file looks like this: import createClient, { ClientOptions } from "openapi-fetch";
import type { paths as Radarr } from "./generated";
export function createRadarrClient(clientOptions?: ClientOptions) {
return createClient<Radarr>(clientOptions);
} But the |
Beta Was this translation helpful? Give feedback.
-
You need to export the types in you index.ts file, without a export the tool dont know what should be exported |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm converting a node API wrapper package (not published on NPM, I just install it using the GitHub path but that doesn't matter I guess) for Aleph X-services to Typescript. I wrote a file
aleph.d.ts
with typings for what the API returns (it responds XML and xml2js converts it to JS objects, which I need types for).The typings file looks like this:
Whenever I build that with tsup (with the
--dst
flag), tsup removes theexport
keyword in the "dist/index.d.ts" file. The rest of the types is output as is to my dist folder, but not theexport
keyword, which makes it impossible to import these types from consumer projects. When I import the functions from same package in a Typescript file of a consumer project, types are inferred correctly (I can click to the definition), but in one case it is not, and I have to cast it manually which cannot be done if the Aleph namespace is not exported correctly.I found, I can just rename the file
aleph.d.ts
toaleph.ts
and addexport * from './aleph'
to myindex.ts
file and everything works but that doesn't feel right as it contains only typings for the API response structure.Am I doing something wrong or is this a bug in tsup?
Beta Was this translation helpful? Give feedback.
All reactions