ryder.dev

Add Typescript to Existing Next.js project with Yarn πŸ§žβ€β™‚οΈ

April 06, 2021

Step 1

In the root folder of your project (where your package.json file is), put this into Terminal:

touch tsconfig.json

Step 2

Now install Typescript into your Next.js app using Yarn:

yarn add typescript @types/react @types/node

Extras

Don’t forget to restart your development server if it’s open in another Terminal.

Also, I would highly recommend adding to the file inclusions in your tsconfig.json file:

  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    "**/*.css", πŸ‘ˆ
    "**.*.js" πŸ‘ˆ
  ],