React js typescript在子文件夹中不工作



我使用typescript与react js。当在src文件夹中创建tsx文件时,Typescript正在工作。但是每当我在子文件夹中使用tsx时,例如ex. components文件夹typescript就不起作用了。

tsconfig.json:

{"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx" }, "include": ["src"] }

使用

查看新生成的tsconfigweb

npx create-react-app——template typescript

npx react-native init MyApp——templatereact-native-template-typescript

在使用vscode时,当你输入组件名 时,还有一个自动建议功能。希望有帮助

最新更新