Repository navigation
Conversation
typeFrom to generate exports for declaration files
typeFrom to generate exports for declaration filesdeclaration option to generate exports for declaration files
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| ] | ||
| expect( | ||
| toExports(imports, undefined, false, { declaration: true }), | ||
| ).toMatchInlineSnapshot(`"export { foo } from 'pkg/dts';"`) |
There was a problem hiding this comment.
| ).toMatchInlineSnapshot(`"export { foo } from 'pkg/dts';"`) | |
| ).toMatchInlineSnapshot(`"export type { foo } from 'pkg/dts';"`) |
Should it be like this as well?
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.
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.