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.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
770
上手に付き合うコンポーネントテスト
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
4.9k
reg-viz VRT tools
quramy
4
1.8k
NoInfer
quramy
0
410
Other Decks in Programming
See All in Programming
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
250
contenteditable と日本語入力に向き合う
colorful12
0
190
カツオ、ご期待ください
suneo3476
0
160
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
180
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
200
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
400
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
150
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
620
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
170
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
350
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
580
Featured
See All Featured
BBQ
matthewcrist
90
10k
Believing is Seeing
oripsolob
1
240
Ethics towards AI in product and experience design
skipperchong
2
420
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
540
[SF Ruby Conf 2025] Rails X
palkan
3
1.4k
How to Ace a Technical Interview
jacobian
280
24k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
530
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
790
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 !