generated at
2/17/2025, 12:32:24 PM
Next.js 9.0.0からTypeScript標準対応
from
Next.js
2019/7/8 9.0.0から標準対応になった
以下は標準対応前の2019.2.18に試したときのログ
TypeScript
で使うサンプル
https://github.com/zeit/next.js/tree/canary/examples/with-typescript
@zeit/next-typescriptをつかう
>
This plugin implements @
babel/preset-typescript
with Next.js.
https://github.com/zeit/next-plugins/tree/master/packages/next-typescript
中身は
babel/preset-typescript
なので、型チェックはしてくれない
詳しくは:
babel/preset-typescript#5c6987ab3f442500001ff2d1
型チェックをする方法
1 TypeScritをいれて
tsc
をする
2
https://www.npmjs.com/package/@zeit/next-typescript#type-checking
の設定をする
Next.jsだと2の方が楽
npm run dev
したときのconsoleにエラー一覧が出る
そもそも
IDEでTS Supportがあればここまでやらなくてもいいかもしれない
参考
Next.js + TypeScript (1) - FIVETEESIXONE