2017-08-11 59 views
5

我已經在使用TypeScript編寫React組件的.Net核心Web應用程序上啓用了Resharper Ultimate。VS17 Resharper對React.Component的投訴

所以我有一個簡單的組件類;

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", 

開發依賴

"@types/react": "^15.0.39", 
"@types/react-dom": "^15.5.1", 

望着類型的文件,我可以看到陣營組件在2個參數需要,因爲它應該:

interface Component<P = {}, S = {}> extends ComponentLifecycle<P, S> { } 
    class Component<P, S> { 
     constructor(props?: P, context?: any); 

我正在使用webpack來編譯TS/TSX文件,並且它正在工作,並且該項目正常工作,但是它正在運行g如果Resharper不能很好地處理TypeScript代碼,會很煩人。

任何人都知道一種方法來解決這個問題?

回答

5

當前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語言支持。這工作正常。

+1

唉感謝您的信息。我會坐下來等待R#v2017.2。 –