You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My goal is to output a lib folder with CommonJS (CJS) modules using TypeScript (tsc) and a special server folder where the index.js is bundled by Rollup (UMD) from /src/server.ts.
The problem arises when I try to generate TypeScript declaration files (*.d.ts) for my /src/server.ts file. By default, TypeScript produces a server.d.ts declaration file, but I want it to match the name of the output file, which is index.js. To address this, I've employed the rollup-plugin-dts to bundle the index.d.ts from /src/server.ts.
However, I've encountered an issue. When I write my source code as follows:
export{Demo};exporttype{IFoo};
The plugin rollup-plugin-dts compiles it to:
export{typeIFoo,ServerDemo};
This is undesirable because export { type IFoo, ServerDemo } is not supported in some older versions of TypeScript projects. How can I turn off this automatic combination and make it compile to the expected:
export{Demo};exporttype{IFoo};
Please note that in lib/server.d.ts, where TypeScript compiles based on my tsconfig, it doesn't exhibit the unexpected merging of exports.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have set up my project as shown in this Git repository: https://github.com/aeroxy/dts-problem-demo
My goal is to output a lib folder with CommonJS (CJS) modules using TypeScript (tsc) and a special server folder where the
index.js
is bundled by Rollup (UMD) from/src/server.ts
.The problem arises when I try to generate TypeScript declaration files (*.d.ts) for my
/src/server.ts
file. By default, TypeScript produces aserver.d.ts
declaration file, but I want it to match the name of the output file, which isindex.js
. To address this, I've employed therollup-plugin-dts
to bundle theindex.d.ts
from/src/server.ts
.However, I've encountered an issue. When I write my source code as follows:
The plugin
rollup-plugin-dts
compiles it to:This is undesirable because export
{ type IFoo, ServerDemo }
is not supported in some older versions of TypeScript projects. How can I turn off this automatic combination and make it compile to the expected:Please note that in
lib/server.d.ts
, where TypeScript compiles based on my tsconfig, it doesn't exhibit the unexpected merging of exports.Beta Was this translation helpful? Give feedback.
All reactions