Repository navigation
Description
Clear and concise description of the problem
Hello:
I recently discovered this project and, firstly, thank you! I was really struggling with figuring out tsconfigs for different packages in a monorepo, and specifically exporting a shared lib to be consumed by both Node.js and a browser environment. This project reduced hours of suffering into a few minutes!
This brings me to my request, and I'm hoping the context will justify it. I am requesting that you reconsider incorporating the work that was done in #253 and #307 and generate a "types" condition export for each entry.
Your comments indicate that the "types" condition is not required, because TypeScript will automatically look for an ambient declaration file when importing. While this true, this behavior is limited to full imports: it does not occur for type-only imports (import type { ... } from ... or import { type ... } from ...). While I freely admit that I am not a savant with TypeScript and there may be better ways to accomplish the goal, there are occasions where I have found it necessary to do type-only imports, as a full import breaks code or creates a circular redundancy. I understand that the "types" condition is not required; however, in these situations, it would be very helpful and I'm not aware of any downsides to it.
I wrote a workaround using the customExports feature that takes a guess at where the ambient declaration file should be and adds a "types" condition. It "works", but it makes some unsafe assumptions: it's fine for my private project, but I wouldn't trust it for public consumption. Furthermore, despite working on it for awhile, I wasn't able to figure out how to access enough data to remove the assumptions and definitively assert the location of the proper declaration files.
Thanks for your time and work on this project
Suggested solution
Based on a review of of generateExports, it seems like it may be possible to add a format for ambient declarations. Then, instead of continuing if the chunk is not an ES or CJ module, you could capture ambient declarations and then store that chunk to subExport for inclusion during genSubExport.
Obviously, I'm no expert at this (or I probably wouldn't have to resort to a cool package like this to bundle my code) and it feels silly to make code suggestions at my experience level. But, it would be really helpful if tsdown generated type conditions and I didn't want to make a request without offering a potential solution.
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Start date
Target date
Effort
Activity
github-actions commentedon Mar 28, 2026
Hello @dever23b! 👋
Thank you for raising an issue. However, we need a minimal reproduction to investigate the problem effectively.
📋 What is a Minimal Reproduction?
A minimal reproduction is the smallest possible project that demonstrates your issue. It should:
Learn more about why reproductions are required: Why Reproductions are Required
🔧 How to Provide a Reproduction
Choose one of the following options:
Use StackBlitz (Recommended for quick sharing)
Use a GitHub Repository
💡 Need Help?
If you're having trouble creating a reproduction or need debugging assistance, consider using Priority Support for dedicated help!
Once you've provided a minimal reproduction, please comment here with the link. We'll be happy to investigate further. Thank you for your understanding! 🙏
sxzz commentedon Mar 28, 2026
Thanks for the detailed write-up! Could you provide a minimal reproduction that demonstrates the case where the missing
typescondition causes an issue? For example, a small repo or StackBlitz showing the type-only import failing to resolve without it. That would help us understand exactly under which circumstances this is needed and evaluate the best approach.dever23b commentedon Mar 28, 2026
Sure! I think I can figure that out. Let me work on it and get back to you.
dever23b commentedon Mar 29, 2026
Well, I have to admit, I'm completely stumped. I was not able to reproduce the issue.
I re-created the design pattern I'm using in a test repo and, when that worked, I rolled back my main project to before I created the customExports workaround and found that that was also working just fine. My best guess is that I got bit again by VS Code and its TS Server randomly acting up.
At the time I submitted this issue, I was consistently getting "Module
modulehas no exported membermember" errors on anyimport typestatements, and the error seemed directly tied to whether my shared lib exported atypescondition. If I re-built the lib withtypesconditions on each export, the main project would see the modules; if I removed thetypescondition, the main project would get flooded with module errors. I tested it several times, but didn't think to restart my TS Server before came here for help.I did extensive testing with different configurations, playing with combinations of customExports and devExport settings. Not only was I unable to reproduce this issue, I couldn't produce any issues. Tsdown is performing perfectly, and I'm very happy with it.
Thanks for the quick response and all your work on this project. It seems I've wasted your time, unfortunately, and I'm sorry about that.