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

useUrlState 设置ts类型识别不到 #2618

Closed
yqw19920202 opened this issue Aug 2, 2024 · 5 comments
Closed

useUrlState 设置ts类型识别不到 #2618

yqw19920202 opened this issue Aug 2, 2024 · 5 comments
Labels
needs more info Needs more information to continue

Comments

@yqw19920202
Copy link

declare const useUrlState: (initialState?: S | (() => S) | undefined, options?: Options) => readonly [Partial<{ [key in keyof S]: any; }>, (s: React.SetStateAction<Partial<{ [key in keyof S]: any; }>>) => void];

这泛型传递后,所有的参数的值都是any类型,应该改成下面这样的吧,不知道正不正确

declare const useUrlState: (initialState?: S | (() => S) | undefined, options?: Options) => readonly [Partial<{ [key in keyof S]: S[key]; }>, (s: React.SetStateAction<Partial<{ [key in keyof S]: S[key]; }>>) => void];

@crazylxr
Copy link
Collaborator

crazylxr commented Aug 5, 2024

怎么划线了,没问题了吗?

@crazylxr crazylxr added the needs more info Needs more information to continue label Aug 5, 2024
Copy link

github-actions bot commented Aug 5, 2024

Hi, yqw19920202.

It seems that this issue is a bit vague and lacks some necessary information.

看起来这条 issue 描述得有些模糊,缺少一些必要的信息。

@yqw19920202
Copy link
Author

declare const useUrlState: (initialState?: S | (() => S) | undefined, options?: Options) => readonly [Partial<{ [key in keyof S]: any; }>, (s: React.SetStateAction<Partial<{ [key in keyof S]: any; }>>) => void];
这个是源码定义的类型,他识别不出来我传递参数的类型,因为他把value都设置层any了

@yqw19920202
Copy link
Author

这个hook希望setState添加第二个参数,可以设置navigateMode,
场景,当我进入一个页面后没有携带search参数,但是我会给默认的值,这时候navigateMode为replace,当我在这个页面做一些路由页面,指向改变search的时候 我希望是push

Copy link

github-actions bot commented Aug 9, 2024

Since the issue was labeled with needs more info, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.
由于该 issue 被标记为需要更多信息,却 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Needs more information to continue
Projects
None yet
Development

No branches or pull requests

2 participants