LoginSignup
1
1

More than 5 years have passed since last update.

自分向け: flowのライブラリをtypescriptにする手順

Posted at
  1. 依存を更新する(まずこれをしないと変なところでハマる可能性があるので1番最初に必ず行う)
  2. flow-typedを削除
  3. yarn remove flow-bin
  4. package.jsonのscriptフィールドを修正しflow関連を削除
  5. yarn add --dev typescript ts-jest @types/jest @akameco/tsconfig (tsconfigは任意)
  6. tsconfigの編集: extendsにakameco/tsconfigを指定しoutDirとtargetとlibの指定
  7. jest.config.jsにpreset ts-jestを追加
  8. eslintの設定(eslint-config-precureを使っていればflowならflow,tsならtsで自動設定されるので変更する必要はないが一応確認)
  9. 拡張子をjs→tsに変更
  10. 必要な@typesのインストール
  11. testを通す
  12. buildを通す
  13. flowをDropするのでリリースする際はメジャーバージョンを上げること

flowからTypeScriptにする構成は2通り考えれるが、

  1. typescript, jest, ts-jest, prettier, eslint
  2. typescript, babel, @babel/preset-typescript, jest, prettier, eslint

ライブラリにおいては、babelと型定義の生成等手間がかかるので基本的にtypescriptオンリーの方がよい。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1