Weitere ähnliche Inhalte
Ähnlich wie 小規模チームで Type script と向き合う話 (20)
小規模チームで Type script と向き合う話
- 7. Spectra, Inc.
Spectra, Inc.
どうして TypeScript を使うのか
7
ランタイムエラーが
起こり得るコード
builder
ビルドエラー
エラーの早期発見ができる
※「型」で排除できないエラーパターンも
当然あるので注意
builder
ビルドOK
適切なコード
※変更箇所、内容によっては
最低限の品質担保が
できているため
自動マージを活用
`compilerOptions.strict = true` を使う!
- 11. Spectra, Inc.
Spectra, Inc.
TypeScript の型システムを活用する
11
● TypeScript には型を便利に使う手段がいろいろ用意されている
○ Utility Types
■ ある型を別の型定義とすることができる
○ Indexed Access Types
■ ある型のあるフィールドの型を参照することができる
○ など
https://www.typescriptlang.org/docs/handbook/utility-types.html
https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html
- 12. Spectra, Inc.
Spectra, Inc.
TypeScript の型システムを活用する
12
● TypeScript Handbook の Type Manipulation の章は非常に有用なので
要チェック
● GraphQL Code Generator などのコード生成ソリューションとの
組み合わせが便利
○ e.g. 生成した types をもとに新たな型をつくる
https://www.typescriptlang.org/docs/handbook/2/types-from-types.html
- 15. Spectra, Inc.
Spectra, Inc.
Dependabot とうまく付き合う
15
● Dependabot を利用して依存ライブラリを最新に維持する
● Dependabot
○ GitHub が買収したライブラリアップグレードの
PR 自動生成ソリューション
https://github.com/dependabot/dependabot-core
https://docs.github.com/ja/code-security/supply-chain-security/keeping-your-dependencies-updated-a
utomatically/about-dependabot-version-updates
- 16. Spectra, Inc.
Spectra, Inc.
Dependabot とうまく付き合う
16
1. Dependabot がアップデート PR を作成する
GitHub Actions
2. GitHub Actions で検証 3. GitHub Actions でマージ
GitHub Actions と組み合わせて自動マージができる
とくに devDependencies は自動マージしやすい
https://docs.github.com/ja/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/auto
mating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
- 18. Spectra, Inc.
Spectra, Inc.
Dependabot とうまく付き合う
18
● Definitely Typed
○ > The repository for high quality TypeScript type definitions.
○ @types/hoge なやつ
○ 対応するライブラリ本体のマイナーバージョンまでと対応関係が
ある
■ = パッチバージョンの更新はライブラリ本体の更新とは
関係ないためビルドが通るなら更新してよい場合が多い
https://github.com/DefinitelyTyped/DefinitelyTyped