Typescript Configuration
As current version of soya next allows extension of next.config.js, now we can build soya-next application that understand typescript.
Installation
Dependencies :
yarn add @zeit/next-typescriptOn your project folder root, add next.config.js
const withTypescript = require('@zeit/next-typescript');
module.exports = withTypescript();and add tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"jsx": "preserve",
"lib": ["dom", "es2017"],
"module": "esnext",
"moduleResolution": "node",
"esModuleInterop": true,
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": false,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "esnext"
}
}and modify .babelrc to use next-typescript preset
Testing with Jest
Dependencies :
Update your jest configuration to resolve typescript and use ts-jest plugin
Custom module resolver
If you use babel-plugin-module-resolver, you need to add .ts and .tsx extensions resolve to the plugins configuration in .babelrc
also update your jest configuration
Last updated