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
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
760
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
280
Are APIs Still Relevant in the AI Era?
soyuka
0
450
ジョジョの世界をXRで再現する
mofurune
0
150
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
370
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
3k
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.6k
JRuby: Past, Present, and Future
headius
0
230
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
240
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
130
プロダクトコードからライブラリの境界を見つける
elmetal
PRO
0
110
mrbgem 三角測量 開発
ogom
0
230
Featured
See All Featured
BBQ
matthewcrist
90
10k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
610
Music & Morning Musume
bryan
48
7.4k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.3k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
540
Code Review Best Practice
trishagee
74
20k
How to Ace a Technical Interview
jacobian
280
24k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
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 !