0

I am using typescript with react js. Typescript is working when creating tsx files in src folder. But whenever I am using tsx in a sub folder like ex. components folder typescript is not working.

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"] }

1 Answers1

0

look at newly generated tsconfig using

for web

npx create-react-app my-app --template typescript

for react native

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

check the dir on your top imports, when using vscode, there's also an auto suggestion feature when you type component name

Hope it helps

gpbaculio
  • 5,693
  • 13
  • 60
  • 102