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
5分でTypeScript入門!〜既存JS環境に引導を渡そう〜
Search
nsym-m
April 23, 2021
Programming
41
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
5分でTypeScript入門!〜既存JS環境に引導を渡そう〜
TypeScriptあんまり触ったことないですが、TS入門のLT資料を作ってみました。
nsym-m
April 23, 2021
More Decks by nsym-m
See All by nsym-m
Flutter入門してみた
nsym
0
130
O’ReillyでGo言語入門
nsym
0
140
Other Decks in Programming
See All in Programming
TechTown - Creating Composable Callables in Contemporary C++
rollbear
0
130
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
190
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
280
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
440
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
Domain-Driven Transformation
hschwentner
2
2.3k
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
160
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
140
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
180
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
Ethics towards AI in product and experience design
skipperchong
2
440
How to make the Groovebox
asonas
2
2.5k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
270
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
The Pragmatic Product Professional
lauravandoore
37
7.5k
A better future with KSS
kneath
240
18k
Tell your own story through comics
letsgokoyo
1
1.1k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
440
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
890
Transcript
5分でTypeScript入門! 〜既存JS環境に引導を渡そう〜
TypeScriptとは? • JavaScriptの静的型付け版の言語 • Microsoftがオープンソースで開発している • Googleでも社内標準言語として利用されている • TypeScriptをJavaScriptにコンパイルして実行する
なぜTypeScript? • 型が保証されている(型推論も使える) • 型があることで改修時のバグ発生率が下がり保守性の向上 • 型を書けるので気持ちがいい(Developer eXperience) • エディタの入力補完を受けられることで開発効率の向上
• 型チェックの厳しさをプロジェクトごと決められる ◦ → 導入障壁が低い!!!
TypeScriptを導入してみよう 弊社のお掃除ロボットるんばちゃんの状況をリアルタイムで知らせる「る んばちゃんbot」のチャットを投稿しているJavaScriptのプログラムに TypeScriptを導入してみようと思います。
ざっくり手順 1. typescriptのinstallとtsconfig.jsonの作成 2. tsconfig.jsonの設定を緩めに指定 3. ファイルの拡張子を .js → .ts
に変更する 4. コンパイルエラーを修正する とっても簡単!!!!(?)
typescriptのinstallと tsconfig.jsonの作成 • typescriptはTypeScriptのコンパイラのモジュール • tsconfig.jsonはTypeScriptコンパイルの設定ファイル
tsconfig.jsonの設定を緩めに指定① • 最初は型チェックに関する設定を緩めにする
tsconfig.jsonの設定を緩めに指定② ☆ポイント • 優先すべきは「TypeScript」導入を完了させること ◦ 「厳密な型を使う」のはあとからでも追加できる • any型を許容する(大事) • 型を緩くしていてもJavaScriptよりも堅い型チェックやエディタによる
補完などのサポートを受けられる
ファイル拡張子を.js → .tsに変更 • `rename`コマンドは追加する必要あり(Mac) • Linuxの`rename`コマンドとは若干違うらしい(未検証) • Windowsの場合は`ren`コマンドが使えそう?(未検証)
コンパイルエラーを修正①
コンパイルエラーを修正② • プロパティを定義していない状態でオブジェクトを作成していたの で、オブジェクト定義の時にプロパティも同時に定義する • ついでに「type」でオブジェクトの型も定義する(必須ではない)
コンパイルエラーを修正③
エラーが出なければOK!! これであなたもTypeScripterの仲間入り!! いざ、ビルド!
ご清聴ありがとうございました。 良いTypeScriptライフを!!!! 参考記事: https://eh-career.com/engineerhub/entry/2019/04/16/103000 https://tech.raksul.com/2019/07/22/introduce-typescript-to-existing-product/ https://komiyak.hatenablog.jp/entry/20170421/1492752232