{{ message }}
feat(toExports): add declaration option to generate exports for declaration files#477
Merged
feat(toExports): add declaration option to generate exports for declaration files#477
declaration option to generate exports for declaration files#477Conversation
typeFrom to generate exports for declaration files
typeFrom to generate exports for declaration filesdeclaration option to generate exports for declaration files
antfu
reviewed
Oct 28, 2025
| ] | ||
| expect( | ||
| toExports(imports, undefined, false, { declaration: true }), | ||
| ).toMatchInlineSnapshot(`"export { foo } from 'pkg/dts';"`) |
Member
There was a problem hiding this comment.
Suggested change
Should it be like this as well?
Contributor
Author
There was a problem hiding this comment.
It seems that toExports does not currently emmit export type, and typeFrom is only concerned with the specifier; but since declaration: true is supposed to be used for declaration files, generating type-only exports with the export type {} from syntax may also be supported.
Imports, however, are "marked" as type-only with the Import.type option. Perhaps when includeType and declaration are set to true, toExports should use export type {} for type-only imports (those with type: true). For reference, generateTypeDeclarations uses toTypeReExports for type-only imports.
antfu
approved these changes
Dec 14, 2025
This was referenced Dec 14, 2025
8 tasks
1 task
This was referenced Feb 5, 2026
This was referenced Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolves #472
optionsparameter totoExports. As mentioned in the issue, other parameters could be incorporated tooptionsin the future.ToExportOptions.declarationto read from imports'typeFromif provided.toImportModule, usetypeFrominstead offromif provided andoptions.declarationistrue. This causestoExportsto usetypeFromas the specifier for generated exports.