
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
@zeit/next-typescript
Advanced tools
Use [Typescript](https://www.typescriptlang.org/) with [Next.js](https://github.com/zeit/next.js)
Use Typescript with Next.js
This plugin implements @babel/preset-typescript with Next.js.
npm install --save @zeit/next-typescript
or
yarn add @zeit/next-typescript
Create a next.config.js
in your project
// next.config.js
const withTypescript = require('@zeit/next-typescript')
module.exports = withTypescript()
Create a .babelrc
in your project
{
"presets": [
"next/babel",
"@zeit/next-typescript/babel"
]
}
Create a tsconfig.json
in your project
{
"compileOnSave": false,
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": false,
"preserveConstEnums": true,
"sourceMap": true,
"skipLibCheck": true,
"baseUrl": ".",
"lib": [
"dom",
"es2016"
]
}
}
Optionally you can add your custom Next.js configuration as parameter
// next.config.js
const withTypescript = require('@zeit/next-typescript')
module.exports = withTypescript({
webpack(config, options) {
return config
}
})
If your IDE or code editor don't provide satisfying TypeScript support, or you want to see error list in console output, you can use fork-ts-checker-webpack-plugin
. It will not increase compile time because it forks type checking in a separate process
// next.config.js
const withTypescript = require("@zeit/next-typescript")
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
module.exports = withTypescript({
webpack(config, options) {
// Do not run type checking twice:
if (options.isServer) config.plugins.push(new ForkTsCheckerWebpackPlugin())
return config
}
})
FAQs
Use [Typescript](https://www.typescriptlang.org/) with [Next.js](https://github.com/zeit/next.js)
The npm package @zeit/next-typescript receives a total of 9,025 weekly downloads. As such, @zeit/next-typescript popularity was classified as popular.
We found that @zeit/next-typescript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.