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
TypeScript LSP の今までとこれから
Search
Yosuke Kurami
June 06, 2025
Programming
2.3k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TypeScript LSP の今までとこれから
Yosuke Kurami
June 06, 2025
More Decks by Yosuke Kurami
See All by Yosuke Kurami
GraphQL の onError と Nullability のこれから
quramy
0
200
フロントエンドテストの育て方
quramy
12
3.9k
App Router 悲喜交々
quramy
8
780
上手に付き合うコンポーネントテスト
quramy
6
2.4k
Patched fetch did not work
quramy
6
820
GraphQL あるいは React における自律的なデータ取得について
quramy
18
6k
Next.js App Router
quramy
15
4k
Fragment Composition of GraphQL
quramy
17
5k
reg-viz VRT tools
quramy
4
1.8k
Other Decks in Programming
See All in Programming
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
670
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
820
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
350
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.5k
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
180
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
500
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
150
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
210
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
330
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
1.3k
Getting Started with Vibe Coding
miccheng
0
160
Featured
See All Featured
Statistics for Hackers
jakevdp
799
230k
Designing for Timeless Needs
cassininazir
1
540
Agile that works and the tools we love
rasmusluckow
331
22k
Believing is Seeing
oripsolob
1
260
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
A Tale of Four Properties
chriscoyier
163
24k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
490
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
730
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
290
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
YesSQL, Process and Tooling at Scale
rocio
174
15k
HDC tutorial
michielstock
2
990
Transcript
TypeScript LSP ͷ ࠓ·Ͱͱ͜Ε͔Β @Quramy 2025.6.6
About me
Today's theme - Corsa ( TypeScript 7.0, Go ݴޠϕʔε) ͰΤσΟλαϙʔτ͕Ͳ͏ͳͬͯ
͍͘ͷ͔ɺࢥ͍Λ͍ͤͯ͘
TypeScript ͷΤσΟλαϙʔτ - Strada(TypeScript < 7) ʹ tsserver ͱ͍͏ϓϩάϥϜ͕ಉࠝ͞Ε͍ͯΔ -
ΤσΟλ (e.g. VSC, Vim, etc, ) tsserver ͱ௨৴͢Δ͜ͱͰϢʔβʔʹίʔ σΟϯάͷศརػೳΛఏڙ͍ͯ͠Δ - ίʔυิ, ΤϥʔνΣοΫ, Quick fi x, Organize Import, etc,,,
Language Server Protocol - LSP (Language Server Protocol) : -
MicroSoft ͕ࡦఆͨ͠ ΤσΟλ - ݴޠαʔϏεؒͷ౷ҰతͳΠϯλʔϑΣΠε - LSP ʹΑΓɺΤσΟλଆ Plugin ͷ࣮ίετ͕֨ஈʹԼ͕Δ -41ͷͳ͍ੈք -41ͷ͋Δੈք
Language Server Protocol ? - tsserver LSP Λ࣮͍ͯ͠ͳ͍ tsserver
should implement the Language Server Protocol #11274 - tsserver LSP ࣮͍ͯ͠ͳ͍ (େࣄͳ͜ͱͳͷͰry tsserver should implement the Language Server Protocol #39459 - TypeScript Λ LSP Ͱѻ͏ͨΊʹɺ3rd party ͷΞμϓλΛט·ͤΔ ͷख͕ؒඞཁͳঢ়گ͕ଓ͍͍ͯΔ 😇
LSP ͷྺ࢙ - 2015.4 ݄ʹ TypeScript 1.5-alpha Ͱ tsserver ͕ެ։͞Εͨ
(߹Θͤͯ MS Sublime Text ͚ͷϓϥάΠϯϦϦʔε͍ͯ͠Δ) - ಉ࣌ظʹ C# (.NET) ͷίϛϡχςΟͰ OmniSharp ͱ͍͏ݴޠαϙʔτ͕։ൃ͞Εͨ - 2015.4 ݄ͷ Build Ͱ VSC ൃදɻ VSC Ͱ OmniSharp, tsserver ͷํʹରԠͤ͞Δ Plugin Λ։ൃ͢ΔաఔͰ LSP ͷߏ ͕࢝·Δ ( https://github.com/microsoft/language-server-protocol/wiki/Protocol-History ) - 2016ʹ Microsoft ͕ LSP Λެ։ LSP ͷ JSON RPC ௨৴༷ tsserver, OmniSharp ͷӨڹΛڧ͘ड͚͍ͯΔɻ ಛʹ tsserver stdio Λτϥϯεϙʔτʹ࠾༻͍ͯ͠ΔͨΊɺࠓͷ LSP ͷૅͱݴͬͯ աݴͰͳ͍
tsserver v.s. LSP - TypeScript ͷ LSP αϙʔτ͕ਐ·ͳ͔ͬͨཧ༝ҎԼ͕ߟ͑ΒΕΔ: - LSP
͕ tsserver / VSC ͕αϙʔτ͍ͯ͠ΔػೳΑΓශऑͩͬͨ ྫ: Diagnostic pull model ( LSP 3.17 Ͱඪ४Խ͞Εͨ) https://github.com/microsoft/TypeScript/issues/39459#issuecomment-774538570 - TypeScript ͷϝϯςφ LSP ൛ͱ tsserver ͱ͍͏2ͭͷ࣮Λμϒϧ ϝϯς͢Δखؒආ͚͍ͨ https://github.com/microsoft/TypeScript/issues/39459#issuecomment-696179304
10ӽ͠ͷԻ͕ʂ - tsserver ͷLSPԽʑͱͯ͠ਐ·ͳ͔͕ͬͨɺ2025.3.11 ʹিܸ͕Δ IUUQTHJUIVCDPNNJDSPTPGU5ZQF4DSJQUJTTVFTJTTVFDPNNFOU
Corsa ͱ tsserver - Corsa Ͱ LSP ϕʔεͷݴޠαʔόʔΛఏڙ༧ఆ https://devblogs.microsoft.com/typescript/announcing-typescript-native-previews/#editor- support-&-lsp-progress
- Preview ൛Ͱ (ݶఆతͰ͋Δ͕) ར༻Մೳɻ tsc -> tsgo ͱҧ͍ɺ୯७ ͳ porting Ͱࡁ·ͣɺҠ২࡞ۀʹ͕͔͔࣌ؒΔɻStrada ͕࣋ͭେྔͷ Integration Test (௨শ Fourslash ) ΛͲ͏ͬͯҠߦͤ͞ΔͷʁͳͲͷ՝ ͋Δ͕ɺண࣮ʹਐΈͦ͏ https://github.com/microsoft/TypeScript/issues/61742
͜͏ͯ͠ TS ΤσΟλ քʹฏ͕๚Εͨ
͜͏ͯ͠ TS ΤσΟλք ʹฏ͕๚Εͨ ͱݴ͍Εͳ͍
͏ͻͱͭͷ "LSP" - TypeScript ʹ Language Service Plugin ͱ͍͏ػߏ͕ଘࡏ͢Δ ϢʔβʔϥϯυଆͰ
TypeScript ͷ Language Service ͕࣋ͭϝιουͷ ॻ͖͕͑Մೳ - ৄ͘͠ @mizdra ͞Μͷ TSKaigi 2025 ൃදࢿྉΛಡΉͱΑ͍ TypeScript Language Service Plugin Ͱ CSS Module ͷ։ൃମݧΛվળ͢Δ - ࣗز͔ͭͷ LS Plugin Λ OSS ͱͯ͠ఏڙ͍ͯ͠ΔͨΊɺ Corsa Ͱ LS Plugin ͕Ͳ͏ͳΔ͔ଞਓࣄͰͳ͍ e.g. ts-graphql-plugin, eslint-typescript-language-service,
LS Plugin ͷجຊ - LS Plugin tscon fi g.json
ͷ plugins ʹهࡌ͢Δ͜ͱͰ༗ޮԽ͞ΕΔ (ҎԼ ts-graphql-plugin ͷREADME ΑΓൈਮ) -
Corsa ͱ LS Plugin - typescript-go ͷ discussion ʹΑΔͱ: https://github.com/microsoft/typescript-go/discussions/455#discussioncomment-12467973
- ۩ମతະఆ͕ͩɺLS ͷ Plugin ػߏͷߏ͋Δͱͷ͜ͱ - LSP ͷ JSON RPC Payload Λ Intercept ͢ΔܗͰߟ͑Ε͍͍ͷͰɺͱͷ͜ͱ - ԼਤͷΑ͏ͳײͩ͡Ζ͏͔ʁ (: ͜Ε Quramy ͷໝΛਤʹ͚ͨͩ͠)
ίʔυϨϕϧͰߟ͑Δ - Strada (TypeScript < 7) ʹ͓͚Δ LS Plugin ͷίʔυҎԼͷΑ͏ͳܗ
export = () => { return { create(info: ts.server.PluginCreateInfo) { const originalLs = info.languageService; return { ...originalLs, getQuickInfoAtPosition(fileName: string, pos: number) { // ݩͷ Language Service ϝιουΛ࣮ߦ const originalResult = originalLs.getQuickInfoAtPosition( fileName, pos ); // ϑΝΠϧͷ AST Λऔಘ const sourceFile = info.project.getSourceFile(fileName as ts.Path); // AST ղੳ const result = analyzeAST(sourceFile, pos); return mergeResult(originalResult, result); }, } satisfies ts.LanguageService; }, }; };
ίʔυϨϕϧͰߟ͑Δ - Corsa ͷੈքͰ...? export = () => { return
{ create(info: ts.server.PluginCreateInfo) { const originalLs = info.languageService; return { ...originalLs, getQuickInfoAtPosition(fileName: string, pos: number) { // ݩͷ Language Service ϝιουΛ࣮ߦ const originalResult = originalLs.getQuickInfoAtPosition( fileName, pos ); // ϑΝΠϧͷ AST Λऔಘ const sourceFile = info.project.getSourceFile(fileName as ts.Path); // AST ղੳ const result = analyzeAST(sourceFile, pos); return mergeResult(originalResult, result); }, } satisfies ts.LanguageService; }, }; }; ϥοϓݩͷݴޠαʔϏεػೳͷݺͼग़͠ ຊ࣭తʹ-41ͷϨεϙϯεͱՁɻ ΠϯλʔηϓλͰஔͰ͖ͦ͏ +4ଆͰ"45ղੳͰ͖ΔΈ͕ඞཁ ͢ͳΘͪɺ$PSTBʹ͓͚Δ$PNQJMFS"1*Ͱ ಉͷ͜ͱ͕Ͱ͖Δͷ͔͕ϙΠϯτ 1MVHJOͷΤϯτϦํࣜΘ͔Βͳ͍͕ɺ Ұ୴Ͳ͔͜Β͔/PEFKTͷϓϩηε͕ىಈ ͞ΕΔͱఆ
(ิ) Corsa ͱ Compiler API - Compiler API ʹ͍ͭͯɺtypescript-go ʹ࠷খݶͷج൫෦
commit ͞Ε͍ͯΔ https://github.com/microsoft/typescript-go/pull/711 - ઌ΄Ͳͷ project.getSourceFile() Ͱ AST Λऔಘ͢ΔՕॴ࣮͞Ε͍ͯΔͨΊɺ Corsa Ҡߦޙ JS ͔Βࠓͱಉ༷ͷײ֮Ͱ AST ղੳΛ࣮Ͱ͖ͦ͏ - getSourceFile ͷ࣮ଶ IPC Ͱ͋Δ͕ɺlibsyncrpc ͕ར༻͞Ε͓ͯΓ JS ଆ͔Βैདྷͷ Compiler API ͱಉ͘͡ಉظతͳݺͼग़͕͠Մೳ
ݸਓతͳؾʹͳΓ - LSP Λ௨Δ JSON RPC Request ͷසͰ Plugin-Native ؒͰ
AST సૹ͕ൃੜ͠ ͯͳ͍ͷ͔ʁ - ྫ: Completion ܥͷίϚϯυίʔυ͕Ϣʔβʔ͕λΠϐϯά͢ΔͨͼʹϦ ΫΤετ͞ΕಘΔ - Plugin ͕ Interceptor ͔Β sourceFile Λཁٻ͢ΔͱɺLSP ͷ RPC ϦΫΤε τຖͰ AST సૹ͕ൃੜ͢Δ (୯७ͳ JSON Ͱͳ͘ Flatten ͳ Uint8Array) Strada Ͱ plugin ίʔυ͕ ಉҰϓϩηεͷ sourceFile ʹΞΫηεͰ͖ ΔͨΊɺߴසͷ document มߋԼͰ TypeScript ͕͍࣋ͬͯΔ Incremental Parse ͷԸܙΛڗडͰ͖͕ͨɺݱঢ় Corsa ͷ IPC ϕʔεͷ API ͰͦΕແཧͦ͏
recap - TypeScript ͱ Language Server Protocol - Corsa ͰΑ͏͘
TypeScript LSP Λਖ਼ࣜʹ໊ΕΔΑ͏ʹͳΔΑ - TypeScript Language Service Plugin - Plugin ػߏͷߏࣗମ͋ΔͷͷɺPlugin ͷϩʔυํࣜ AST స ૹΦʔόʔϔουͳͲɺෆ໌ྎͳ෦ґવͱͯ͠ଟ͍ - ൺֱతඋ͕ਐΜͰ͍Δ Compiler API पΓ͔Β͏ͱΑͦ͞͏
Thank you !