Browse Source

fix: 修复类型问题 & 增加类型导出 (#116)

July 9 months ago
parent
commit
05b287f3f8

+ 4 - 2
packages/node-engine/form/src/core/create-form.ts

@@ -11,7 +11,7 @@ import { FieldArrayModel } from './field-array-model';
 //   parentContainer?: interfaces.Container;
 // }
 
-type CreateFormOptions = FormOptions & {
+export type CreateFormOptions<T = any> = FormOptions<T> & {
   /**
    * 为 true 时,createForm 不会对form 初始化, 用户需要手动调用 control.init()
    * 该配置主要为了解决,用户需要去监听一些form 的初始化事件,那么他需要再配置完监听后再初始化。
@@ -20,7 +20,9 @@ type CreateFormOptions = FormOptions & {
   disableAutoInit?: boolean;
 };
 
-export function createForm<TValues>(options?: CreateFormOptions): CreateFormReturn<TValues> {
+export function createForm<TValues>(
+  options?: CreateFormOptions<TValues>
+): CreateFormReturn<TValues> {
   const { disableAutoInit = false, ...formOptions } = options || {};
   const formModel = new FormModel();
 

+ 1 - 1
packages/node-engine/form/src/core/index.ts

@@ -1,5 +1,5 @@
 export { FormModel } from './form-model';
-export { createForm } from './create-form';
+export { createForm, type CreateFormOptions } from './create-form';
 export { FieldModel } from './field-model';
 export { FieldArrayModel } from './field-array-model';
 

+ 2 - 2
packages/node-engine/form/src/index.ts

@@ -16,10 +16,10 @@ export type {
   Field as IField,
   Form as IForm,
   Errors,
-  Warnings
+  Warnings,
 } from './types';
 
 export { ValidateTrigger } from './types';
-export { createForm } from './core/create-form';
+export { createForm, type CreateFormOptions } from './core/create-form';
 export { Glob } from './utils';
 export * from './core';