寻找关于在我的React项目中导入.tsx或.ts文件的适当设置的建议。目前,我正在将.js文件转换为.tsx,并且只在导入时使用@ts-ignore,但我希望正确配置所有内容。有什么建议吗?
下面是我的ts-config文件:
"compilerOptions": {
"target": "es2016",
"module": "esnext",
"noImplicitAny": true,
"esModuleInterop": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"strict": true,
"jsx": "react-jsx",
"allowJs": true,
"checkJs": false,
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
},
"include": [
"src"
]
}发布于 2021-12-06 20:50:08
npx create-react-app my-app --template typescript额外好处:React TypeScript Cheatsheets可能也值得一查。它在Migrating (to Typescript)上有一个页面
https://stackoverflow.com/questions/70239119
复制相似问题