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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yosuke Kurami
June 06, 2025
Programming
2.2k
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
フロントエンドテストの育て方
quramy
12
3.9k
App Router 悲喜交々
quramy
8
760
上手に付き合うコンポーネントテスト
quramy
6
2.4k
Patched fetch did not work
quramy
6
810
GraphQL あるいは React における自律的なデータ取得について
quramy
18
6k
Next.js App Router
quramy
15
4k
Fragment Composition of GraphQL
quramy
17
4.9k
reg-viz VRT tools
quramy
4
1.8k
NoInfer
quramy
0
410
Other Decks in Programming
See All in Programming
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
120
アクセシビリティから考える情報設計
high_g_engineer
0
380
JRuby: Past, Present, and Future
headius
0
180
Agents on Rails - Rails at Scale 2026
irinanazarova
0
150
What We Talk About When We Talk About XP
m_seki
2
670
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.7k
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
560
setup-vp GitLab対応の裏側
naokihaba
0
120
Workers Cache を知る
syumai
0
190
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
900
SREの越境 / SRE Collaboration
y0hgi
2
270
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
440
Featured
See All Featured
Amusing Abliteration
ianozsvald
1
310
Code Reviewing Like a Champion
maltzj
528
40k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
280
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
WCS-LA-2024
lcolladotor
0
830
BBQ
matthewcrist
89
10k
The Limits of Empathy - UXLibs8
cassininazir
1
690
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
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 !