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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
160
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
130
コーディング自動化の次へ。人の介入をゼロにするファクトリーとサポートAIによる実践
timakin
5
5k
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
310
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
4
1.4k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
300
SODA - FACT BOOK(EN)
sodainc
1
200
Apple Intelligenceとオンデバイス時代の到来
yahir0
0
190
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
270
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.1k
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.6k
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
490
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Building Applications with DynamoDB
mza
96
7.3k
From π to Pie charts
rasagy
1
430
First, design no harm
axbom
PRO
2
1.4k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
330
sira's awesome portfolio website redesign presentation
elsirapls
0
490
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 !