From bae3786956b724c20a3f35e6e99381a4561b057e Mon Sep 17 00:00:00 2001 From: yoyo837 Date: Thu, 3 Dec 2026 08:14:36 +0800 Subject: [PATCH] fix: keep type re-exports compatible with TypeScript < 5.0 `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. --- src/index.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 22f9a7c..47a2b52 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,7 +19,27 @@ import { messages as defaultMessages, newMessages } from './messages'; import { asyncMap, complementError, convertFieldsError, deepMerge, format, warning } from './util'; import validators from './validator/index'; -export type * from './interface'; +export type { + ExecuteRule, + ExecuteValidator, + InternalRuleItem, + InternalValidateMessages, + Rule, + RuleItem, + RuleType, + RuleValuePackage, + Rules, + SyncErrorType, + SyncValidateResult, + ValidateCallback, + ValidateError, + ValidateFieldsError, + ValidateMessages, + ValidateOption, + ValidateResult, + Value, + Values, +} from './interface'; /** * Encapsulates a validation schema.