我用npx create-react-app myApp --template typescript
命令创建了我的第一个typescript项目,但是我得到了错误TS2691: An import path cannot end with a '.tsx' extension. Consider importing './components/header.js' instead.
。我已经在互联网上寻找这个错误,但我没有找到任何东西。
我也得到了错误ERROR in src/components/header.tsx TS1208: 'header.tsx' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement to make it a module.
App.tsx:
import './App.css';
import Header from './components/header.tsx';
import Main from './components/main.tsx';
import Footer from './components/footer.tsx';
function App() {
return (
<>
<Header></Header>
<Main></Main>
<Footer></Footer>
</>
);
}
export default App;
footer.tsx:
function Footer(){
return (
<footer>
<p>Desenvolvido por Priscila Alves, e-mail: priscila.contato@live.com</p>
</footer>
);
}
export default Footer;
package.json:
{
...
"scripts": {
"start": "react-scripts start",
"build": "tsc",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
...
1条答案
按热度按时间4bbkushb1#
这个配置到你的webpack配置文件:
将这些规则添加到您的打印脚本中-eslint