Emit .d.ts for type-only usage of .d.ts files in a project #38146
Labels
Needs Proposal
This issue needs a plan that clarifies the finer details of how it could be implemented.
Suggestion
An idea for TypeScript
Search Terms
type only export import declaration declarations .d.ts 3.8
Suggestion
When building code has
.d.ts
files written and used internally, the declarations aren't emitted. This makes sense currently because.d.ts
files aren't compiled. However, it causes typechecking errors when exporting content from the package for external usage, since the declaration isn't included in the compiled output.import/export type
made some initial progress for me by removing the types from the compiled JS output. but I believe it would be even more useful to re emit declarations for type only import exports. this would ensure that ambient declarations are included in the final compiled output.My issue may be incorrect usage of declaration files, which I've only been using due to the external code generation using it. I'm not sure I explained my idea clearly, but I believe my below examples should cover it - please follow up if not.
Use Cases
I have an existing project that exports declarations generated by an external package from non-JS code. The original code doesn't need to be included, just the types for usage by external consumers. When I want to reexport those declarations, I have to manually copy them over to the build folder after since they disappear. You can see an example of this here
Examples
given directory structure
and usage
the output structure should be
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: