DEV Community

Discussion on: Build A Simple Quiz App, with React Hooks & Typescript

Collapse
 
douglasamarelo profile image
Douglas "Amarelo" Lopes

I think you can already start the project with typescript.

  npx create-react-app my-app --template=typescript
Enter fullscreen mode Exit fullscreen mode
Collapse
 
catperry profile image
Cat Perry

Create React App does come ready to convert to a Typescript app, so in one sense you're right. (Which means you can start changing relevant .js files to .ts or .tsx files, which will automatically add a tsconfig.json file and then during compile time your CRA will just tell you to then install typescript.)

However, by using CRA's template for Typescript (--template typescript or --template=typescript) in this step, 1) all relevant Create React App files are added into the app with the .ts or .tsx extension already for you, 2) all typescript packages and dependencies are added for you, and 3) a tsconfig.json file is also created for you. Which includes basic Typescript settings such as this. So CRA Templates do a little more setup for you.

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
douglasamarelo profile image
Douglas "Amarelo" Lopes

Thanks for the answer!