Skip to content

refactor: use explicit named type re-exports - #37

Merged
zombieJ merged 1 commit into
masterfrom
fix/export-type-compat
Dec 3, 2026
Merged

zombieJ merged 1 commit into
masterfrom
fix/export-type-compat

Conversation

@yoyo837

@yoyo837 yoyo837 commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Aligns src/index.ts with 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 * from './interface';
+export type * from './interface';

export type * is TypeScript 5.0 syntax and is emitted verbatim into lib/index.d.ts and es/index.d.ts. Checked the published declarations of @rc-component/input, select, picker, util, trigger, form, table and tree: none of them ship export type *; they all use explicit named exports (export { ... } / export type { ... }).

Change

src/index.ts now lists the type-only exports explicitly:

export type {
  ExecuteRule,
  ExecuteValidator,
  InternalRuleItem,
  InternalValidateMessages,
  Rule,
  RuleItem,
  RuleType,
  RuleValuePackage,
  Rules,
  SyncErrorType,
  SyncValidateResult,
  ValidateCallback,
  ValidateError,
  ValidateFieldsError,
  ValidateMessages,
  ValidateOption,
  ValidateResult,
  Value,
  Values,
} from './interface';

The public type surface is unchanged: interface.ts exports exactly these 19 names, verified by diffing the exported-name sets in both directions. @typescript-eslint/consistent-type-exports is satisfied without an eslint-disable, and the emitted declaration keeps the export * shape that 6.0.0 ships.

Side benefit

Because the declaration no longer uses export type *, consumers on TypeScript 4.x with skipLibCheck: false (the default) also stop failing with TS1383: Only named exports may use 'export type'. That only affects the merged-but-unreleased master; the published 6.0.0 already emits export * and is fine.

Verification

  • npm run compile (eslint + father build) passes.
  • Consumer project, tsc --noEmit, skipLibCheck: false: TypeScript 4.7.4 / 4.9.5 / 5.0.4 / 5.9.3 / 6.0.3 all pass, importing Schema plus every re-exported type.
  • Runtime unchanged: the packed tarball's lib/index.d.ts is export * from './interface' + export default Schema; require(...) + validate works.
  • 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 on master and unrelated to this file.

`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.
Copilot AI balanced review requested due to automatic review settings December 3, 2026 00:15
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

src/index.ts 将 ./interface 的通配类型重导出改为显式类型列表。未列入列表的类型不再通过此入口导出。

Changes

类型导出调整

Layer / File(s) Summary
显式列出重导出类型
src/index.ts
入口现在显式重导出 ExecuteRule、ExecuteValidator、SyncValidateResult、Value 等类型及原有类型。未列入清单的类型不再通过此入口导出。

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested reviewers: afc163

Merge Risk: Minimal · up to bae37

This change makes the package's type re-exports compatible with TypeScript 4.x consumers. The public type surface and runtime behavior are not expected to change, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题“refactor: use explicit named type re-exports”描述了本 PR 的主要变更:将 src/index.ts 中的通配类型重导出 export type * from './interface' 改为显式命名的类型重导出。标题与变更集直接相关,且具体、简洁。PR 目标是兼容 TypeScript 4.x 的声明生成,标题未提及兼容性动机,但这不影响主…
Full details: Title check

Explanation

标题“refactor: use explicit named type re-exports”描述了本 PR 的主要变更:将 src/index.ts 中的通配类型重导出 export type * from './interface' 改为显式命名的类型重导出。标题与变更集直接相关,且具体、简洁。PR 目标是兼容 TypeScript 4.x 的声明生成,标题未提及兼容性动机,但这不影响主要变更的描述。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

我是兔子,捧来类型清单,
一项一项,列得明明白白。
通配出口收起了耳朵,
显式导出排成整齐队列。
我蹦过入口,轻轻说声好。

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a08dea0-8aa0-4b0a-8ebd-09a6f6f22c2a
Commits

Reviewing files that changed from the base of the PR and between 8cca839 and bae3786.

Files selected for processing: 1

  • src/index.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit bae3786.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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

@yoyo837 yoyo837 changed the title fix: keep type re-exports compatible with TypeScript < 5.0 refactor: use explicit named type re-exports Dec 3, 2026
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.38%. Comparing base (8cca839) to head (bae3786).

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.
📢 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.

@zombieJ
zombieJ merged commit 4d9e214 into master Dec 3, 2026
13 of 14 checks passed
@zombieJ
zombieJ deleted the fix/export-type-compat branch December 3, 2026 07:31
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.

3 participants