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

[Field]field.setValue支持传递值泛型 #4852

Open
xmsz-stu opened this issue May 21, 2024 · 5 comments
Open

[Field]field.setValue支持传递值泛型 #4852

xmsz-stu opened this issue May 21, 2024 · 5 comments
Assignees
Labels
💬 Discussion improvement improve some features

Comments

@xmsz-stu
Copy link

Component

Field

Feature Description

希望支持

    setValue<T>(name: string, value: T, reRender?: boolean, triggerChange?: boolean): void;

我看之前是支持的,后面又去掉了
支持这个的好处就是我可以约束和提示值,不然不好检查

@eternalsky eternalsky added improvement improve some features Next release issues to close in next release labels May 29, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in DAILY WORK May 29, 2024
@eternalsky eternalsky self-assigned this May 29, 2024
@eternalsky eternalsky added 💬 Discussion and removed improvement improve some features labels Jun 27, 2024
@eternalsky eternalsky moved this from 🆕 New to ✅ Done in DAILY WORK Jun 27, 2024
@eternalsky eternalsky removed the Next release issues to close in next release label Jun 27, 2024
@eternalsky
Copy link
Contributor

这个问题仔细想了一下,这里如果使用泛型并符合 TS 中关于函数泛型的推荐范式,即至少有两处使用到该类型时才使用。这里如果希望约束 value 的类型,我觉得更好的方式是 setValue 时 as Type

@github-project-automation github-project-automation bot moved this from ✅ Done to Ready to release in DAILY WORK Jun 27, 2024
@eternalsky eternalsky moved this from Ready to release to ✅ Done in DAILY WORK Jun 27, 2024
@xmsz-stu
Copy link
Author

as type会遇到多传的情况
type A = {a:number}
setState({a:1,b:2} as A) // 是能通过的,但是实际上不想通过,因为有可能这个属性有副作用

@eternalsky eternalsky reopened this Sep 23, 2024
@eternalsky
Copy link
Contributor

有道理

Copy link

你好,该 issue 已 30 天没有活动,因此被标记为 stale,如果之后的 7 天仍然没有活动,该 issue 将被自动关闭

@github-actions github-actions bot added the Stale not active for a lone time label Oct 23, 2024
@eternalsky eternalsky added improvement improve some features and removed Stale not active for a lone time labels Oct 29, 2024
@eternalsky
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💬 Discussion improvement improve some features
Projects
Archived in project
Development

No branches or pull requests

2 participants