【发布时间】:2021-07-21 00:14:56
【问题描述】:
考虑在我们的应用程序中采用 redux-toolkit,但我似乎无法获得我们为动作创建者展示的文档集。
旧代码:
const ADD_NAME = 'ADD_NAME';
/**
* Sets the name for the user in our state.
* @param name The updated name
*/
export function addName(name: string) {
return {
payload: name,
type: ADD_NAME,
};
}
在 VSCode 中,每当我发送 addName() 时,将鼠标悬停在函数上都会按预期提供带有文档的工具提示。
使用 redux-toolkit 重新创建这个动作创建器:
/**
* Sets the name for the user in our state.
* @param name The updated name of the User
*/
export const addName = createAction<string>(ADD_NAME);
当我在调度期间将鼠标悬停在这个新的 addName 上时,而不是看到我写的文档:
Sets the name for the user in our state.
我看到了:
Calling this {@link redux#ActionCreator} with an argument will return a {@link PayloadAction} of type T with a payload of P
这是 redux-toolkit 类型文件中ActionCreatorWithPayload 的内部文档。
我为我的 addName 动作创建者添加的 doc cmets 而不是 redux-toolkit doc cmets,我错过了什么?
我意识到一个是我在评论一个函数,另一个是在评论一个 const var,但我希望我的 cmets 将 addName const 显示为工具提示,不是吗?
【问题讨论】:
标签: typescript redux redux-toolkit