Reactjs React无法使用Typescript编译

Reactjs React无法使用Typescript编译,reactjs,typescript,Reactjs,Typescript,React无法识别Typescript语法,并且我收到此错误 $ yarn start yarn run v1.22.5 $ react-scripts start (node:12196) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module r esolution of the package at C:

React无法识别Typescript语法,并且我收到此错误

    $ yarn start
yarn run v1.22.5
$ react-scripts start
(node:12196) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module r
esolution of the package at C:\Users\tmerc\OneDrive\Escritorio\SoyHenry\app\node_modules\postcss-safe-parser\nod
e_modules\postcss\package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
i 「wds」: Project is running at http://192.168.1.102/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from C:\Users\tmerc\OneDrive\Escritorio\SoyHenry\app\admin-front\pub
lic
i 「wds」: 404s will fallback to /
Starting the development server...
Failed to compile.

./src/components/SelectCourseAndCohort/index.tsx
SyntaxError: C:\Users\tmerc\OneDrive\Escritorio\SoyHenry\app\admin-front\src\components\SelectCourseAndCohort\index.tsx: Unexpected token, expected "," (12:36)

  10 | const useStyles = makeStyles(styles);
  11 |
> 12 | function SelectCourseAndCohort(props: PropsSelectCourseAndCohort) {
     |                                     ^
  13 |
  14 |   const { courseInfo, setCourseInfo, courses, cohorts } = props;
我今天在这台计算机上安装了这个项目,在其他计算机上这个问题不存在。
感谢您如果使用react-typescript,功能组件需要如下所示:

const SelectCourseAndCohort:FC<PropsSelectCourseAndCohort> = (props) =>{
//
}
const selectCourseandShort:FC=(道具)=>{
//
}
与JavaScript中的React不同,您需要导入FC或FunctionalComponent以访问这些内容,这是由于在TypeScript中React

还有一个问题,为什么要使用react脚本start 而不仅仅是npm启动,因为同样的问题解决了! 这个项目是一个子项目,root用户也有node_模块。我和这个有冲突。 我删除了根项目和所有子项目中的所有
node_模块
,以及所有
warn.lock
。然后,我做了纱线和解决问题。
谢谢你的回答

在package.json中有typescript吗?@RomiHalasz有<代码>“typescript”:“^4.0.3”`不起作用。现在表示预期的“(”,比如如果不认识到我正在使用TS。我使用“纱线开始”,然后运行react脚本start@TomásMercado可以显示代码plz和package.json吗