Originally posted: 2021-04-06
Super simple code to add TS to your existing Next.js app using Yarn instead of NPM.
In the root folder of your project (where your package.json
file is), put this into Terminal:
touch tsconfig.json
Now install Typescript into your Next.js app using Yarn:
yarn add typescript @types/react @types/node
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" 👈
],