How to export typings from a node package #935
verheyenkoen
started this conversation in
General
Replies: 1 comment
-
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.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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