告诉 Resharper 忽略 node_modules 中的 lib 文件夹
Telling Resharper to ignore lib folder in node_modules
我们又来了,又一个月又一次 Resharper 更新,在使用节点模块和@types 时似乎破坏了 TypeScript 中的所有内容
我正在使用 TypeScript、React 和 Redux,所以使用 npm 包 redux-actions
和 @types/redux-actions
有各种强类型的 ReduxActions
我的代码如下所示:
const pageReducer = handleActions<IPageState, number | string>({
[actionTypes.doSomething]: (state: IPageState, action: Action<string>): IPageState => {
// some code to manipulate the state
return {}; // returning the manipulated state
},
[actionTypes.doSomethingElse]: (state: IPageState, action: Action<number>): IPageState => {
// some code to manipulate the state
return {}; // returning the manipulated state
}
}, initialState()); // initial state function which returns initial state object
IPageState
是一个具有各种属性的接口。
一切都通过 webpack 编译和捆绑,运行起来非常棒,所以代码没有问题。在过去的 2 年里,我们一直在使用这种模式,并且运行良好。
然而,随着最新的 Resharper 更新(版本 2017.3),它现在抱怨 handleActions<IPageState, number | string>
Untyped function calls may not accept type arguments
我注意到 Resharper 似乎正在查看文件 /node_modules/redux-actions/lib/index.js
以获取所有内容的定义,而不是查看 /node_modules/@types/redux-actions/index.d.ts
文件。因此,如果我删除 lib
文件夹,所有 Resharper 错误都会消失。
有没有办法告诉 Resharper 忽略 lib
文件夹?我不能只删除它,因为在进行全新安装时,该文件夹会重新出现。
我也有同样的问题。到目前为止,我发现的唯一方法是在我的一个反应组件的顶部为类型定义添加一个三重斜杠指令(我把它放在 app.tsx 中,这是我的应用程序的主要反应组件), 例如
/// <reference path="./../../node_modules/@types/react/index.d.ts"/>
将此添加到源中的单个文件似乎足以修复项目范围内的错误 R# 错误。不理想,我不知道它为什么会起作用,但到目前为止它似乎已经解决了我的问题。
这是 Resharper 中的一个错误,现已修复。 https://youtrack.jetbrains.com/issue/RSRP-467712
如果您下载最新版本的 Resharper,问题现已解决。
我们又来了,又一个月又一次 Resharper 更新,在使用节点模块和@types 时似乎破坏了 TypeScript 中的所有内容
我正在使用 TypeScript、React 和 Redux,所以使用 npm 包 redux-actions
和 @types/redux-actions
我的代码如下所示:
const pageReducer = handleActions<IPageState, number | string>({
[actionTypes.doSomething]: (state: IPageState, action: Action<string>): IPageState => {
// some code to manipulate the state
return {}; // returning the manipulated state
},
[actionTypes.doSomethingElse]: (state: IPageState, action: Action<number>): IPageState => {
// some code to manipulate the state
return {}; // returning the manipulated state
}
}, initialState()); // initial state function which returns initial state object
IPageState
是一个具有各种属性的接口。
一切都通过 webpack 编译和捆绑,运行起来非常棒,所以代码没有问题。在过去的 2 年里,我们一直在使用这种模式,并且运行良好。
然而,随着最新的 Resharper 更新(版本 2017.3),它现在抱怨 handleActions<IPageState, number | string>
Untyped function calls may not accept type arguments
我注意到 Resharper 似乎正在查看文件 /node_modules/redux-actions/lib/index.js
以获取所有内容的定义,而不是查看 /node_modules/@types/redux-actions/index.d.ts
文件。因此,如果我删除 lib
文件夹,所有 Resharper 错误都会消失。
有没有办法告诉 Resharper 忽略 lib
文件夹?我不能只删除它,因为在进行全新安装时,该文件夹会重新出现。
我也有同样的问题。到目前为止,我发现的唯一方法是在我的一个反应组件的顶部为类型定义添加一个三重斜杠指令(我把它放在 app.tsx 中,这是我的应用程序的主要反应组件), 例如
/// <reference path="./../../node_modules/@types/react/index.d.ts"/>
将此添加到源中的单个文件似乎足以修复项目范围内的错误 R# 错误。不理想,我不知道它为什么会起作用,但到目前为止它似乎已经解决了我的问题。
这是 Resharper 中的一个错误,现已修复。 https://youtrack.jetbrains.com/issue/RSRP-467712
如果您下载最新版本的 Resharper,问题现已解决。