-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: generic type for getDataValue #346
Conversation
setDataValue(key: string, value: Literal | Literal[]): void; | ||
getDataValue(key?: string): Literal | { [key: string]: Literal }; | ||
setDataValue<T, Key extends keyof T>(this: T, key: Key, value: T[Key]): void; | ||
getDataValue<T>(this: T): T; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啊?这样不对吧?
是不是没办法 getDataValue<T>(this: T, key: string): T[key]
这样
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overload 没问题啊,本身不传值返回的就是 this,传值就是 this[key] 👇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看懂啦,会不会有点太麻烦了😂
你们模型层切换到 ts 了没,已经切换的话,this.getDataValue<User['id']> 可以用 this.id 平替呀
No description provided.