【WIP】【FOR CR ONLY】实现了一个debounce #12
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
实现了个type-safe的plugin;
实践下来的想法是:
1.1. defineStore函数用了很多推导,由用户代码推导类型,比如你写了 state 包含一个test,初始值是string类型,那么action拿到的store就包含这个test
1.2. 问题来了:plugin如果要依赖state或者action,那么这个时候,你没写完你的定义时,ts会因为你没写完等原因导致推导无法进行,也就是,debounce里没法拿到action的key作为代码提示,只能等你写完之后再校验
1.3. 也因为是推导校验,所以ts只知道你写的类型“互相不匹配”,但不知道以哪个为准,所以彪红会整个定义彪