This package has been deprecated

    Author message:

    Next.js now has built-in TypeScript support that is integrated into the framework by default: https://nextjs.org/docs/basic-features/typescript

    @zeit/next-typescript
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/zeit__next-typescript package

    1.1.1 • Public • Published

    Next.js + Typescript

    Use Typescript with Next.js

    This plugin implements @babel/preset-typescript with Next.js.

    Installation

    npm install --save @zeit/next-typescript
    

    or

    yarn add @zeit/next-typescript
    

    Usage

    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
      }
    })

    Type checking

    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
      }
    })

    Keywords

    none

    Install

    npm i @zeit/next-typescript

    DownloadsWeekly Downloads

    13,423

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    5.41 kB

    Total Files

    5

    Last publish

    Collaborators

    • nalalami
    • mbrakken
    • wyattjoh
    • pearlbea
    • gt-codes
    • sowsut
    • jennifer_stern
    • kaiyuhsu
    • matthewstanciu
    • hannesborno
    • lubakravche
    • aaronbrown-vercel
    • denizkusef
    • javierbyte
    • kayernyc
    • janory
    • goncy
    • codyogden
    • feedthejim
    • tilly3g
    • wits
    • feugy
    • gbibeaulaviolette
    • megbird
    • dizzyup
    • vin-e
    • edgarcerecerezv
    • livcarman
    • segunadebayo
    • sambecker
    • craigandrews
    • mjakobis
    • kale-stew
    • chloe.tedder
    • pbto
    • daniel.campbell
    • arian-vercel
    • nuta
    • almonk
    • samselikoff
    • dcartertwo
    • baruchadi
    • ejc
    • aaorris
    • doque
    • ryanto
    • nathanhammond
    • snokohn
    • johnphamous
    • tknickman
    • agadzik
    • thomcrowe
    • emeraldsanto
    • ecklf
    • timeyoutakeit
    • cramforce
    • balazs4
    • casey.gowrie
    • samuel.foster
    • swarnavasengupta
    • lydiahallie
    • ethan_arrowood
    • kwonoj
    • kakadiadarpan
    • amanhimself_
    • endangeredmassa
    • nick.tracey
    • reconbot
    • schlez
    • crowterli
    • gsoltis
    • epallerols
    • domysee
    • nwienert
    • arbw
    • stephdietz
    • gudmundur
    • marcgreenstock
    • vvo
    • falcoagustin
    • nabsul
    • bmealey
    • maedahbatool
    • brethudson
    • matt.straka
    • jasongullickson
    • f3d0r
    • gaspar09
    • jtaylor0196
    • pieparker
    • kelly
    • dferber90
    • healeycodes
    • broph123
    • codybrouwers
    • gdborton
    • jeffreyarneson
    • ebb-tide
    • msimulcik
    • domeccleston
    • nutlope
    • hungrybearstudio
    • codetaromiura
    • gkaragkiaouris
    • geovanisouza92
    • dglsparsons
    • lostinpatterns
    • vercel-release-bot
    • southpolesteve
    • matheuss
    • igorklopov
    • nkzawa
    • tootallnate
    • rauchg
    • timneutkens
    • javivelasco
    • iamevilrabbit
    • kdy1
    • quietshu
    • styfle
    • zeit-bot
    • lucleray
    • mglagola
    • andybitz
    • paulogdm
    • anatrajkovska
    • timer
    • arzafran
    • ijjk
    • lfades
    • msweeneydev
    • williamli
    • ragojose
    • guybedford
    • skllcrn
    • janicklas-ralph
    • atcastle
    • spanicker
    • housseindjirdeh
    • gmonaco
    • kikobeats
    • prateekbh
    • jkrems
    • jaredpalmer
    • gielcobben
    • chibicode
    • nazarenooviedo
    • samsisle
    • okbel
    • hankvercel
    • leerobinson
    • elsigh
    • julianbenegas
    • rizbizkits
    • sokra
    • cl3arglass
    • chriswdmr
    • ernestd
    • ismaelrumzan
    • jhoch
    • mitchellwright
    • mrmckeb
    • kuvos
    • creationix
    • huozhi
    • cmvnk
    • ktcarter
    • padmaia
    • delba
    • catsaremlg
    • steventey
    • gsandhu
    • dbredvick