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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Keisuke Ikeda
May 23, 2025
Programming
240
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
210
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
190
Docコメントで始める簡単ガードレール
keisukeikeda
1
190
初めてのLisp自作譚
keisukeikeda
0
50
Other Decks in Programming
See All in Programming
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.9k
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.8k
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
720
源内ハンズオン概要編
hideg
0
230
仕様駆動開発の消費期限
watany
20
9.2k
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
630
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
120
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
410
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.1k
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
280
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
360
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
100
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
660
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
460
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
290
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
880
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
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