Skip to content

Conversation

@8ctavio
Copy link
Contributor

@8ctavio 8ctavio commented Oct 9, 2025

Resolves #472

  • Add a new options parameter to toExports. As mentioned in the issue, other parameters could be incorporated to options in the future.
  • Add ToExportOptions.declaration to read from imports' typeFrom if provided.
  • In toImportModule, use typeFrom instead of from if provided and options.declaration is true. This causes toExports to use typeFrom as the specifier for generated exports.

@8ctavio 8ctavio changed the title Feat 1 feat(toExports): use typeFrom to generate exports for declaration files Oct 9, 2025
@8ctavio 8ctavio changed the title feat(toExports): use typeFrom to generate exports for declaration files feat(toExports): add declaration option to generate exports for declaration files Oct 9, 2025
@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.67%. Comparing base (a4a5e0a) to head (7d752b0).
⚠️ Report is 134 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #477      +/-   ##
==========================================
- Coverage   98.73%   97.67%   -1.06%     
==========================================
  Files          14       15       +1     
  Lines        1817     1463     -354     
  Branches      374      479     +105     
==========================================
- Hits         1794     1429     -365     
- Misses         23       34      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

]
expect(
toExports(imports, undefined, false, { declaration: true }),
).toMatchInlineSnapshot(`"export { foo } from 'pkg/dts';"`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
).toMatchInlineSnapshot(`"export { foo } from 'pkg/dts';"`)
).toMatchInlineSnapshot(`"export type { foo } from 'pkg/dts';"`)

Should it be like this as well?

Copy link
Contributor Author

@8ctavio 8ctavio Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add toExports support for declaration files

2 participants