Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tsconfigのオプションで変わる型世界
Search
Keisuke Ikeda
May 23, 2025
Programming
230
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
tsconfigのオプションで変わる型世界
https://2025.tskaigi.org/talks/ike_keichan
Keisuke Ikeda
May 23, 2025
More Decks by Keisuke Ikeda
See All by Keisuke Ikeda
JavaScript実装の自作プログラミング言語をTypeScript実装に移行した話
keisukeikeda
1
190
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
170
Docコメントで始める簡単ガードレール
keisukeikeda
1
170
初めてのLisp自作譚
keisukeikeda
0
39
Other Decks in Programming
See All in Programming
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
810
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
190
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.4k
Vite+ Unified Toolchain for the Web
naokihaba
0
360
はてなアカウント基盤 State of the Union
cockscomb
1
830
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.5k
スマートグラスで並列バイブコーディング
hyshu
0
260
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
220
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
950
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
300
Featured
See All Featured
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
470
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
My Coaching Mixtape
mlcsv
0
150
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
What's in a price? How to price your products and services
michaelherold
247
13k
ラッコキーワード サービス紹介資料
rakko
1
3.7M
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Test your architecture with Archunit
thirion
1
2.3k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
290
Transcript
UTDPOGJHͷΦϓγϣϯͰ มΘΔܕੈք ,FJTVLF*LFEB 54,BJHJ !JLF@LFJDIBO
自己紹介 02/16 ,FJTVLF*LFEB ɾ౦ژͱؔʢେࡕ&ژʣͷ2ڌੜ׆த ɾTSKaigi 2025, ϑϩϯτΤϯυΧϯϑΝϨϯεؔ 2025ͷελοϑ ɾษڧձେ͖Ϛϯ, ษڧձதͷπΠʔτ͕͏Δ͍͞
ɾ࠷ۙί̋μᘖᘣͷϞʔχϯάʹϋϚͬͯΔ
tsconfigに向き合おう! 03/16 tsconfig ΛͪΌΜͱݟͨ͜ͱ͋Γ·͔͢ʁ
tsconfigに向き合おう! 04/16 ɾσϑΥϧτઃఆͰͷӡ༻ ɾࣗͷϙδγϣϯతʹؔΘΔػձ͕ͳ͍ ɾϓϩδΣΫτͷ్தࢀըͷͨΊઃఆෆཁ ɾ࠷ॳʹઃఆͯ͠Ҏ߱ɺݟ͞ͳ͍ ɾֶशͰߏจܕͷॻ͖ํͳͲ͕༏ઌ ɾଞπʔϧͷઃఆʹຒΕ͍ͯΔ UTDPOGJH͕ݟա͝͞Ε͕ͪͳཧ༝ ֶͿɾݟ͢ػձͷܽɹ
tsconfigに向き合おう! 05/16 ͜ͷൃදͰߦ͏͜ͱ ɾॳ৺ऀ͚ʹֶͿɾݟͨ͢Ίͷ͖͔͚ͬΛఏڙ ɾ۩ମతʹʁ ɹ- ॳظઃఆʢtsc --initʣͷ tsconfig.json ΛϕʔεʹɺҰ෦ͷΦϓγϣϯ
ɹɹΛมߋ͠ɺ͋͑ͯʮܕʯΛ؇ ɹ- ઃఆͷมߋͰܕ҆શੑ͕Ͳ͏มΘΔ͔Λݕূ ɾʮܕͷ͋Γ͕ͨΈʯͱʮઃఆͷॏཁੑʯΛ࣮ײ
tsconfigに向き合おう! 06/16 ͜ͷLTͰ tsconfig ΛֶͿɾݟ͖͔͚ͬ͢ʹʂ ʢͳΕخ͍͠ʣ
5ZQF4DSJQU%PDVNFOUBUJPOʮ$PNQJMFS0QUJPOTʯ ݄Ҿ༻ IUUQTXXXUZQFTDSJQUMBOHPSHKBUTDPOGJH オプションによる変化 07/16 ܕʹؔ͢ΔΦϓγϣϯ ݱࡏʢʣશ෦ͰΦϓγϣϯ
45&1ɿॳظঢ়ଶ index.ts オプションによる変化 08/16 type User = { id: number;
name: string; }; class UserManager { // TS2564:プロパティが未初期化 private users: User[]; // TS7006:引数が暗黙的にany型 addUser(user) { this.users.push(user); return user.id; } findUserById(id: number): User | null { const foundUser = this.users.find((user) => user.id === id); // TS2322:型の不一致 "User | undefined"型 return foundUser; } getUserName(id: number): string { const user = this.findUserById(id); // TS18047:usersがnullable return user.name; } } tsconfig.json { "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "strict": true, "skipLibCheck": true, "outDir": "./dist" }, "include": ["src/*.ts"], "exclude": ["node_modules"] }
45&1ɿॳظঢ়ଶ index.ts オプションによる変化 09/16 type User = { id: number;
name: string; }; class UserManager { // TS2564:プロパティが未初期化 private users: User[]; // TS7006:引数が暗黙的にany型 addUser(user) { this.users.push(user); return user.id; } findUserById(id: number): User | null { const foundUser = this.users.find((user) => user.id === id); // TS2322:型の不一致 "User | undefined"型 return foundUser; } getUserName(id: number): string { const user = this.findUserById(id); // TS18047:usersがnullable return user.name; } } tsconfig.json { "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "strict": true, "skipLibCheck": true, "outDir": "./dist" }, "include": ["src/*.ts"], "exclude": ["node_modules"] } 54ϓϩύςΟ͕ະॳظԽ 54Ҿ͕҉తʹBOZܕ 54ܕͷෆҰகʢOVMMͱVOEFGJOFEͷ۠ผʣ 54ฦΓ͕OVMMBCMF
มߋ͢ΔͭͷΦϓγϣϯ オプションによる変化 10/16 ɾstrictPropertyInitialization ɹ- ΫϥεͷϓϩύςΟ͕ॳظԽ͞Ε͍ͯΔ͔ΛνΣοΫ ɾstrictNullChecks ɹ- null ͱ
undefined Λݫີʹ۠ผ&νΣοΫ ɾnoImplicitAny ɹ- ҉తʹ any ܕΛνΣοΫ
45&1ɿϓϩύςΟॳظԽνΣοΫແޮ index.ts オプションによる変化 11/16 type User = { id: number;
name: string; }; class UserManager { // TS2564:プロパティが未初期化 private users: User[]; // TS7006:引数が暗黙的にany型 addUser(user) { this.users.push(user); return user.id; } findUserById(id: number): User | null { const foundUser = this.users.find((user) => user.id === id); // TS2322:型の不一致 "User | undefined"型 return foundUser; } getUserName(id: number): string { const user = this.findUserById(id); // TS18047:usersがnullable return user.name; } } tsconfig.json { "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "strict": true, + "strictPropertyInitialization": false, "skipLibCheck": true, "outDir": "./dist" }, "include": ["src/*.ts"], "exclude": ["node_modules"] } Τϥʔআ
45&1ɿOVMMͱVOEFGJOFEͷݫີͳ۠ผˍνΣοΫແޮ index.ts オプションによる変化 12/16 type User = { id: number;
name: string; }; class UserManager { // TS2564:プロパティが未初期化 private users: User[]; // TS7006:引数が暗黙的にany型 addUser(user) { this.users.push(user); return user.id; } findUserById(id: number): User | null { const foundUser = this.users.find((user) => user.id === id); // TS2322:型の不一致 "User | undefined"型 return foundUser; } getUserName(id: number): string { const user = this.findUserById(id); // TS18047:usersがnullable return user.name; } } tsconfig.json { "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "strict": true, "strictPropertyInitialization": false, + "strictNullChecks": false, "skipLibCheck": true, "outDir": "./dist" }, "include": ["src/*.ts"], "exclude": ["node_modules"] } Τϥʔআ Τϥʔআ
45&1ɿ҉తͳBOZܕͷνΣοΫແޮ index.ts オプションによる変化 13/16 type User = { id: number;
name: string; }; class UserManager { // TS2564:プロパティが未初期化 private users: User[]; // TS7006:引数が暗黙的にany型 addUser(user) { this.users.push(user); return user.id; } findUserById(id: number): User | null { const foundUser = this.users.find((user) => user.id === id); // TS2322:型の不一致 "User | undefined"型 return foundUser; } getUserName(id: number): string { const user = this.findUserById(id); // TS18047:usersがnullable return user.name; } } tsconfig.json { "compilerOptions": { "target": "es2016", "module": "commonjs", "esModuleInterop": true, "strict": true, "strictPropertyInitialization": false, "strictNullChecks": false, + "noImplicitAny": false, "skipLibCheck": true, "outDir": "./dist" }, "include": ["src/*.ts"], "exclude": ["node_modules"] } Τϥʔআ ίϯύΠϧ࣌ͷΤϥʔ͕શͯফ͑ͯ͠·ͬͨ…
࣮ߦͰ͖ͳ͍ϓϩάϥϜ index.ts オプションによる変化 14/16 const manager = new UserManager(); //
strictPropertyInitialization:falseにより見落とされるエラー // 実行時エラー: Cannot read properties of undefined (reading 'push') const user = { id: 1, name: '山田太郎' }; manager.addUser(user); // strictNullChecks:falseにより見落とされるエラー // 実行時エラー: Cannot read properties of undefined (reading 'find') const nonExistentUser = manager.findUserById(999); // noImplicitAny:falseにより見落とされる不具合 // 実行エラーにもならず許容されてしまう。 const incompleteUser = { name: true }; manager.addUser(incompleteUser);
オプションによる変化 15/16 ͦͷΦϓγϣϯʢͷมߋʣඞཁ͔ʁ ɾྫʹڍ͛ͨΦϓγϣϯΛΓସ͑Δඞཁ͕͋Δͷ͔ʁ ɹ- શͯͷϓϩδΣΫτ͕࠷৽ͷόʔδϣϯϕετϓϥΫςΟεʹͰ͖ͯ ɹɹ͍ΔΘ͚Ͱͳ͍ɻ ɹ- TypeScriptҠߦதͷϓϩδΣΫτͰஈ֊తʹಋೖ͍ͯ͠Δ߹ͳͲ ɹɹڐ༰ͤ͟ΔΛಘͳ͍͜ͱ͋Δɻ
ɾԿ͔͠Βͷधཁ͕͋Δ͔ΒΦϓγϣϯଘࡏ͍ͯ͠Δɻ
まとめ 16/16 ·ͱΊ ɾࠓճڍ͛ͨΦϓγϣϯҎ֎ʹ100ݸҎ্ͷΦϓγϣϯ͕ଘࡏ ɹ- ΑΓྑ͍ઃఆΛ͢ΔͨΊʹ֮͑Δඞཁͳ͍͕ɺ ɹɹͬ͘͟ΓͲΜͳछྨͷΦϓγϣϯ͕ଘࡏ͢Δ͔Δ͜ͱ͕େࣄʂ ɾෆཁʹࢥ͑ΔΦϓγϣϯϓϩδΣΫτʹΑͬͯඞཁʂ ɾϓϩδΣΫτຖʹదͳઃఆΛʂtsconfigΛઃఆͯ͘͠Εͨਓʹײँʂ
宣伝 ϑϩϯτΤϯυΧϯϑΝϨϯεؔ 2025 ଓใSNSͰ֬͝ೝ͍ͩ͘͞ʂ Xɿhttps://x.com/fec_kansai Blueskyɿhttps://bsky.app/profile/fec-kansai.bsky.social