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
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
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
170
信頼性の目標を誰も求めてない
shubox
0
450
片田舎のおっさん、 Swift Buildのダイアモンド問題解決の不具合修正PRを出すが、解決方法がキャッシュをしないようにすることであり、ビルド時間が伸びると言われてマージされないので高速化もする/swiftbuild
yimajo
0
330
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
220
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.1k
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
280
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.8k
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
850
仕様駆動開発の消費期限
watany
20
9.2k
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
270
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
200
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
300
The Invisible Side of Design
smashingmag
301
52k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
New Earth Scene 8
popppiees
3
2.5k
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
490
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
400
Joys of Absence: A Defence of Solitary Play
codingconduct
1
460
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
290
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
630
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