gpt4 book ai didi

reactjs - 找不到文件。 typescript react

转载 作者:行者123 更新时间:2023-12-05 06:48:30 31 4
gpt4 key购买 nike

我不熟悉在新的 React 项目中实现 Typescript。

我运行了 yarn create react-app my-app --template typescript,我想知道哪些文件不适合我,我可以删除。与 js 一样,我删除所有内容,只保留 app.js、app.css 和索引。

但是,当我在这里执行时出现错误。

错误告诉我:

undefined TypeScript error in undefined(undefined,undefined): File '/mnt/d/NodeJs/my-todo-list/src/App.test.tsx' not found.   The file is in the program because:
Matched by include pattern 'src' in '/mnt/d/NodeJs/my-todo-list/tsconfig.json' TS6053

我的 tsconfig.json:

{
"name": "my-todo-list",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

我想知道我可以删除的所有内容以启动一个与 typescript react 的新项目,包括我是否可以删除文件 react -应用程序-env.d.tsreportWebVitals.ts

树源: enter image description here

最佳答案

转到您的编辑器 settings.json(在 vscode 中使用 ctrl + shift + p for win),然后放入并保存

"typescript.validate.enable":true,

关于reactjs - 找不到文件。 typescript react ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66822991/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com