Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TS 未経験者が 社内向け JS ライブラリを TS に置き換えている話
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
pvcresin
November 20, 2019
Technology
460
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TS 未経験者が 社内向け JS ライブラリを TS に置き換えている話
https://oweb.connpass.com/event/149918/
#OWEB で発表した内容になります。
pvcresin
November 20, 2019
More Decks by pvcresin
See All by pvcresin
プロポーザルを書いてもらう
pvcresin
0
660
関係性から理解する"同一性"の型用語たち
pvcresin
2
800
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
650
Reduxモダナイズ 〜コードのモダン化を通して、将来のライブラリ移行に備える〜
pvcresin
2
1k
text-box-trim について 1 分で
pvcresin
0
180
Web IDEの進化とそれを支える技術
pvcresin
0
160
ステップアップOSSコントリビュート
pvcresin
0
540
Webアプリケーションのアーキテクチャパターンから読み解くNext.js
pvcresin
0
470
Eight WebフロントエンドのDX向上に関する取り組み
pvcresin
0
220
Other Decks in Technology
See All in Technology
仕様駆動開発の、その先へ。決める力と確かめる仕組み
inariku
1
150
AIエージェント時代、Kaggleにどう取り組むか
takanao
2
450
Flutter Webを「SDK」として配る — 50以上のゲームを支える埋め込みアーキテクチャ
masayukisuda
0
170
Lint の層を組み直した話
bengo4com
1
270
Claude for Google Workspaces ポン出し/claude-for-google-workspace-slide-conversion
emiki
0
13k
スマートロックを支えるFlutter × ネイティブ連携の実践 / Flutter and Native Integration in Practice: Powering Smart Locks
bitkey
PRO
0
130
あなたのDartコードは丸見えかもしれない ~reFlutterで暴くFlutterアプリの中身と多層防御~
zozotech
PRO
0
720
新卒エンジニア、 介護士になる
ryu1013
1
650
2拠点SRE活動始めてみた | sogaoh's LT @ ホンマでっかSRE勉強会 #3
sogaoh
PRO
0
220
Patterns in AI Driven Software Development
akosma
PRO
0
410
キヨさん、67歳。AIコーディングエージェントに挑む
happysamurai294
0
130
AIコーディングはじめました
miso
0
120
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
109
250k
Building Adaptive Systems
keathley
44
3.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Rails Girls Zürich Keynote
gr2m
96
14k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
340
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
Paper Plane
katiecoart
PRO
5
54k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
290
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
380
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Transcript
TS 未経験者が 社内向け JS ライブラリを TS に置き換えている話 @pvcresin OWEB #9
鳥山 らいか / Raika Toriyama Sansan 株式会社 Eight 事業部 フロントエンドエンジニア @pvcresin
JavaScript に静的型付けがついた言語 TypeScript とは
• API の定義ファイルをパースし、フロントエンドで使うデータ形式の JS ファイルを自動生成 • 安全で硬い作りにしたい 社内向けライブラリ フロントエンド バックエンド
API の定義ファイル
やったこと
Step1: 学ぶ
• 公式ドキュメント https://www.typescriptlang.org/docs/home.html • Qiita:TypeScript の型入門 https://qiita.com/uhyo/items/e2fdef2d3236b9bfe74a • 記事:がんばらない TypeScript
https://employment.en-japan.com/engineerhub/entry/2019/04/16/103000 • 書籍:実践 TypeScript 吉井 健文 (著) 参考になったもの
Step2: 準備
• 1ファイルずつ置き換えていく • 型チェックと変換には tsc コマンドを採用 導入方法を決める tsc いままで これから
/src /src /compiled /dist /dist
Step3: 置き換え
拡張子でルールを分けるよう変更 ESLint の設定
場所 • よく薦められるのはテストコードから • 今回はライブラリ本体のコードから始めた • テストコードがない部分があった • 本体のコードが何をしているか不明な場所が多かった ファイル
• 外部のライブラリのみ import しているもの • import がないもの • 他のファイルを import しているもの 置き換える順番
• DefinitelyTyped:http://definitelytyped.org/ ◦ @types/<package name> で探す • npm:https://www.npmjs.com/ ◦ 型定義している
package がないか探す • 自分で定義 ◦ デフォルトだと src/@types/*.d.ts 型定義ファイル
導入してよかったこと
• 型安全でない実装がエラーにより可視化された • JS の 暗黙的な型変換 に助けられていた部分が浮き彫りに • 関数がやるべきことに向き合えた •
場合によっては分割 • 命名の再考 • ある種のテスト代わりになった 導入してよかったこと
現状
None
俺たちの戦いはこれからだ