TypeScript を使用して反応アプリを作成しようとしています。yarn create react-app (name) --use-pnp --typescript を実行しました。
TS リンターは、モジュール 'react'.ts(2307) が見つかりませんと言い続けています。
import React, { Component } from 'react';
import './App.css';
interface IAppState {
}
interface IAppProps {
}
class App extends React.Component<IAppProps, IAppState> {
constructor(props: IAppState) {
super(props);
this.state = {
};
}
render() {
return (
<div className='App'>
<h1>Image classification with ML5.js</h1>
</div>
);
}
}
export default App;
私のpackage.json
{
"name": "image-recognition",
"version": "0.1.0",
"private": true,
"installConfig": {
"pnp": true
},
"dependencies": {
"@types/jest": "24.0.13",
"@types/node": "12.0.2",
"@types/react": "^16.8.17",
"@types/react-dom": "^16.8.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"typescript": "3.4.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
私のtsconfig.json:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve"
},
"include": [
"src"
]
}
yarn add @types/react、yarn add、VScode の再起動などを試しました。