Tim*_*mes 8 resharper typescript reactjs tsx visual-studio-2017
我在一个使用TypeScript编写React组件的.Net核心Web应用程序上打开了Resharper Ultimate.
所以我有一个简单的组件类;
export class Index extends React.Component<{},{}>{
Resharper警告我
Generic type '_$_$RsRpExt"FromFile;....\node_modules\@types\react\index.d.ts, module=JavaScriptReferencedFilesModule:Referenced external files".React.Component' requires 1 type argument(s), but got 2
我的npm包反应是;
依赖关系:
"react": "^15.6.1",
"react-dom": "^15.6.1",
Run Code Online (Sandbox Code Playgroud)
Dev Dependencies
"@types/react": "^15.0.39",
"@types/react-dom": "^15.5.1",
Run Code Online (Sandbox Code Playgroud)
查看类型化文件,我可以看到React Component应该接收2个参数:
interface Component<P = {}, S = {}> extends ComponentLifecycle<P, S> { }
class Component<P, S> {
constructor(props?: P, context?: any);
Run Code Online (Sandbox Code Playgroud)
我正在使用webpack来编译TS/TSX文件,它一切正常,项目正常工作,但如果Resharper不能很好地使用TypeScript代码,那将会很烦人.
有人知道解决这个问题的方法吗?
Tim*_*ard 14
在 VisualStudio 2019 / Resharper 2019.1 中,您现在可以在 JS 文件中启用 JSX 语法。您可以按照以下步骤执行此操作:
扩展 - Resharper - 选项 - JavaScript - 检查 - 在 JS 文件中启用 JSX 语法:始终
我还将我的 JavaScript 语言级别更改为 ECMAScript 2016,但我认为这没有必要。
当前的Resharper版本(2017.1)仅支持TypeScript 2.2.React类型定义使用通用参数默认值,这是一个TypeScript 2.3功能,Resharper 2017.1无法正确识别.Resharper 2017.2(目前在EAP中)将支持TypeScript 2.4.
与此同时,我刚刚关闭了Resharper的JavaScript/TypeScript支持(通过Resharper => Options => Products and Features)并使用VS TypeScript语言支持.这很好用.
归档时间: |
|
查看次数: |
1806 次 |
最近记录: |