Repository navigation
refactor: use explicit named type re-exports - #37
Conversation
`export type * from './interface'` (from the repository maintenance commit)
emits the same syntax into `lib/index.d.ts` and `es/index.d.ts`, which only
TypeScript 5.0+ can parse. Consumers still on TypeScript 4.x fail with
`error TS1383: Only named exports may use 'export type'` whenever they type
check without `skipLibCheck`.
`interface.ts` only contains types, so list them explicitly with
`export type { ... }` instead. The emitted declaration keeps the exact same
public type surface but is valid TypeScript 3.x/4.x syntax.
Verified against TypeScript 4.7 / 4.9 / 5.0 / 5.9 with skipLibCheck disabled.
|
No actionable comments were generated in the recent review. Walkthrough
Changes类型导出调整
Estimated code review effort: 1 (Trivial) | ~3 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the TypeScript declaration-export compatibility change.
No open issues 🎉
What changed in this PR
Restores TypeScript 4.x compatibility for the package’s declaration exports without changing its public type surface or runtime behavior.
Changes:
- Replaces
export type *with explicit named type exports. - Preserves all 19 public types while retaining type-export lint compliance.
| File | Description |
|---|---|
src/index.ts |
Explicitly re-exports types using syntax compatible with older TypeScript compilers. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #37 +/- ##
=======================================
Coverage 82.38% 82.38%
=======================================
Files 25 25
Lines 653 653
Branches 236 238 +2
=======================================
Hits 538 538
Misses 114 114
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Aligns
src/index.tswith the explicit named re-export style used by the rest of the react-component packages, instead of a bare star re-export.Background
1ec8907(chore: standardize repository maintenance) changed the re-export to:export type *is TypeScript 5.0 syntax and is emitted verbatim intolib/index.d.tsandes/index.d.ts. Checked the published declarations of@rc-component/input,select,picker,util,trigger,form,tableandtree: none of them shipexport type *; they all use explicit named exports (export { ... }/export type { ... }).Change
src/index.tsnow lists the type-only exports explicitly:The public type surface is unchanged:
interface.tsexports exactly these 19 names, verified by diffing the exported-name sets in both directions.@typescript-eslint/consistent-type-exportsis satisfied without an eslint-disable, and the emitted declaration keeps theexport *shape that6.0.0ships.Side benefit
Because the declaration no longer uses
export type *, consumers on TypeScript 4.x withskipLibCheck: false(the default) also stop failing withTS1383: Only named exports may use 'export type'. That only affects the merged-but-unreleasedmaster; the published6.0.0already emitsexport *and is fine.Verification
npm run compile(eslint + father build) passes.tsc --noEmit,skipLibCheck: false: TypeScript 4.7.4 / 4.9.5 / 5.0.4 / 5.9.3 / 6.0.3 all pass, importingSchemaplus every re-exported type.lib/index.d.tsisexport * from './interface'+export default Schema;require(...)+validateworks.npm test: 115/116 pass. The single failure (tests/promise.spec.ts› "Whether to remove the 'Uncaught (in promise)' warning",ReferenceError: _ref2 is not defined) is pre-existing onmasterand unrelated to this file.