前提・実現したいこと
typescriptの入門のため、react + typescriptを使ったWebAppを作成しようと考えていたのですが、@types/react/index.d.tsが原因でyarn start
するとエラー画面が表示されます。
エラーの解消方法をご存知でしたらご教授いただきたいです。
発生している問題・エラーメッセージ
create-react-app ts-app --scripts-version=react-scripts-ts
で作成したプロジェクトでyarn start
すると以下のエラーが表示されます。
terminal
1$ create-react-app ts-app --scripts-version=react-scripts-ts 2$ cd ts-app 3$ yarn start 4 5Failed to compile. 6 7/Users/taku-ando/Desktop/react-app/ts-app/node_modules/@types/react/index.d.ts 8(2305,19): Interface 'Element' cannot simultaneously extend types 'ReactElement<any>' and 'ReactElement<any>'. 9 Named property 'type' of types 'ReactElement<any>' and 'ReactElement<any>' are not identical.
該当のソースコード
VSCodeを使用しており、/node_modules/@types/react/index.d.tsをエディタで開くと構文エラーが出ていました。
[ts] インターフェイス 'ElementClass' で型 'Component<any, {}, any>' と型 'Component<any, {}, any>' を同時には拡張できません。 'Component<any, {}, any>' 型および 'Component<any, {}, any>' 型の名前付きプロパティ 'refs' が一致しません。 [2320]
typescript
1declare global { 2 namespace JSX { 3 // tslint:disable-next-line:no-empty-interface 4 interface Element extends React.ReactElement<any> { } 5 interface ElementClass extends React.Component<any> {
試したこと
nodeやtypescriptのバージョンを変更したり、@typesを最新のものに更新してみたのですが、解決しませんでした。
補足情報(FW/ツールのバージョンなど)
- macOS Mojave v10.14
- node: v8.13.0
- @types/jest@23.3.1
- @types/node@10.9.4
- @types/react@16.4.13
- @types/react-dom@16.0.7
- husky@0.14.3
- lint-staged@7.2.2
- prettier@1.14.2
- react@16.4.2
- react-dom@16.4.2
- react-scripts-ts@2.17.0
- typescript@2.3.4
見当違いなことを書いていたらすみません。
お手数ですがよろしくお願いいたします。
あなたの回答
tips
プレビュー