Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

children()函数参数类型定义错误 #517

Closed
danel996 opened this issue Jul 18, 2022 · 2 comments
Closed

children()函数参数类型定义错误 #517

danel996 opened this issue Jul 18, 2022 · 2 comments

Comments

@danel996
Copy link

danel996 commented Jul 18, 2022

版本号 (version)
@form-create/element-ui@3.1.11

问题描述 (Issue)
参考 #72 中的代码
return maker.input('商品价格', 'price', '100').children([maker.create('span').slot('append').children(['元'])]);

上述代码在ts中会报类型错误:

不能将类型“Creator<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>”分配给类型“string | RuleChildren<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>”。

复现步骤
文件:@form-create\core\types\index.d.ts第308行
问题: BaseCreateor.children()参数类型声明错误
children(prop: Array<RuleChildren<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs> | string>): this;

// 为了简化描述, <OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs> 泛型参数就不写了
export type RuleChildren = FormRule[] | RuleChildrenFn<OptionAttrs, CreatorAttrs, RuleAttrs, ApiAttrs>;
export type FormRule = Rule | Creator;

如果忽略泛型中的string类型, 最终children()函数的参数可以表述为:
children(prop: Array<Creator[]>): this;

原因: children()需要的是一个 Array<Creator[]>, 而传递给它的是一个 Array

@xaboy
Copy link
Owner

xaboy commented Jul 18, 2022

感谢反馈,下个版本修复

@xaboy
Copy link
Owner

xaboy commented Aug 21, 2022

最新版本已修复

@xaboy xaboy closed this as completed Aug 21, 2022
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

No branches or pull requests

2 participants