昨日、すべてのTypeScript + Reactプロジェクトで問題なく動作しました。今日は何も変わらず、これまでどんな構成にも壊れています。 Gitを使って作業バージョンに戻すことは役に立ちません。すべてのパッケージをNPMで再インストールしても問題ありません。TypeScript +突然、互換性のない小道具のエラーが発生しました
エラーを見つけるためにApp.jsxのすべてをリッピングしようとしました。
これは私のapp.jsx
import * as React from 'react';
import { BrowserRouter as Router, Route } from 'react-router-dom';
interface Props {}
class App extends React.Component<Props> {
render() {
return (
<div className="App">
<Router>
<div>
<Route exacty={true} path="/" component={<p>Hello</p>}/>
</div>
</Router>
</div>
);
}
}
export default App;
である。しかし、これはまだ私にエラーを与える:私が持っている
(10,5): error TS2605: JSX element type 'BrowserRouter' is not a constructor function for JSX elements.
Types of property 'setState' are incompatible.
Type '{ <K extends never>(f: (prevState: void, props: BrowserRouterProps) => Pick<void, K>, callback?: ...' is not assignable to type '{ <K extends never>(f: (prevState: {}, props: any) => Pick<{}, K>, callback?:() => any): void; <...'.
Types of parameters 'f' and 'f' are incompatible.
Type '(prevState: {}, props: any) => Pick<{}, any>' is not assignable to type '(prevState: void, props: BrowserRouterProps) => Pick<void, any>'.
Types of parameters 'prevState' and 'prevState' are incompatible.
Type 'void' is not assignable to type '{}'.
問題が小道具で、単にすべてのコンポーネントが壊れているということです。たとえば、私のヘッダーのようなコンポーネントがある場合I get an error such as this ヘッダーは空のPropsオブジェクトを持つコンポーネントです。それはreact-router
ため https://pastebin.com/FSyCA1BB
react-router-domの入力が壊れているようです:https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17437 – helb
よろしくお願いします。私はバージョンを変更しました。今度は、Namespace 'React'にはエクスポートされたメンバー 'AnchorHTMLAttributes'がないと言われています。すべてのNPMモジュールを再インストールするという提案は何もしませんでした。 –