"isolatedModules": true, /* to match webpack loader */
"jsx": "preserve", /* Preserves jsx outside of Next.js. */
"lib": ["dom", "es2017"], /* List of library files to be included in the type checking. */
"module": "esnext", /* Specifies the type of module to type check. */
"moduleResolution": "node", /* Determine how modules get resolved. */
"noEmit": true, /* Do not emit outputs. Makes sure tsc only does type checking. */
/* Strict Type-Checking Options, optional, but recommended. */
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"strict": true, /* Enable all strict type-checking options. */
"target": "esnext" /* The type checking input. */
}
}
```
```
After adding the `tsconfig.json` you need to install `@types` to get proper TypeScript typing.
Next.js will automatically configure this file with default values if you (providing [your own `tsconfig.json`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) is also supported).
Then, run `next dev` (normally `npm run dev`) and Next.js will guide you through installing the necessary packages to complete setup.
Now can change any file from `.js` to `.ts` / `.tsx` (tsx is for files using JSX). To learn more about TypeScript checkout its [documentation](https://www.typescriptlang.org/).
You're now ready to start converting files from `.js` to `.tsx` and leveraging the benefits TypeScript provides!
To learn more about TypeScript checkout its [documentation](https://www.typescriptlang.org/).
> **Note**: Next.js will create a file named `next-env.d.ts` in the root of your project.
> This file ensures Next.js' types are picked up by the TypeScript compiler.
>
> **You cannot remove this file, however, you can edit it (but don't need to).**
> **Note**: Next.js does not enable TypeScript's `strict` mode by default.
> When you feel comfortable with TypeScript, you may turn this option on in your `tsconfig.json`.