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
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
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
260
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
950
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
260
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Oxcを導入して開発体験が向上した話
yug1224
4
340
A2UI という光を覗いてみる
satohjohn
1
160
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
120
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
750
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.4k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
950
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
400
act1-costs.pdf
sumedhbala
0
120
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
BBQ
matthewcrist
89
10k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
300
Designing Experiences People Love
moore
143
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
470
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
330
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
250
The browser strikes back
jonoalderson
0
1.3k
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