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
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
tsc.rip を支える技術 / Kyoto.なんか #8
Search
Susisu
August 22, 2026
Programming
4.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
tsc.rip を支える技術 / Kyoto.なんか #8
-
Kyoto.なんか #8
-
tsc.rip
Susisu
August 22, 2026
More Decks by Susisu
See All by Susisu
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
290
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
2.4k
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
susisu
7
2.9k
君だけのオリジナル async / await を作ろう / TSKaigi 2025
susisu
20
16k
null or undefined
susisu
25
8k
Mackerel のフロントエンドフレームワーク移行 序章 / Hatena Engineer Seminar #13
susisu
0
2.3k
スクリーンショット撮影のために Puppeteer を操る / Kyoto.js 16
susisu
0
1k
BuckleScript 使ってみた
susisu
0
440
Atom パッケージ開発のすゝめ
susisu
1
2.3k
Other Decks in Programming
See All in Programming
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
130
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
Webプラットフォームで議論されているセキュリティ課題 / Security issues being discussed on Web Platforms
petamoriken
0
290
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.6k
LLMは4年分のCompose移行を再現できるのか?実プロダクト279件のXMLで探る自動化の境界線
makun
0
450
信頼性の目標を誰も求めてない
shubox
0
500
Foundry Localでエージェント開発
seosoft
0
150
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
3
380
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
100
標準パッケージに uuid が追加された 背景から見る Go らしい意思決定 / go_127_uuid_decision
convto
4
3.5k
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
55
10k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
590
Designing for Timeless Needs
cassininazir
1
470
How to Think Like a Performance Engineer
csswizardry
28
2.8k
KATA
mclloyd
PRO
35
15k
Optimizing for Happiness
mojombo
378
71k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
250
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
320
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
400
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Music & Morning Musume
bryan
47
7.4k
Transcript
tsc.ripを支える技術 id:susisu / 2026-08-22 Kyoto.なんか #8
こんにちは • id:susisu です • 株式会社はてな Webアプリケーションエンジニア/ シニアエンジニア • 文字はデカければデカいほど
良い
tsc.rip • 2026 年 7 月 8 日に TypeScript 7.0
がリリース • コンパイラ (tsc) の実装が TypeScript から Go に移植され高速化 • tsc.rip はこれを記念して作った Web サイト
tsc.rip を支える技術 • AWS 静的サイト 激安 • CloudFront • Lambda
(Function URL) • Go 製 Web サーバー + Lambda Web Adapter
tsc.rip を支える技術 • AWS 静的サイト 激安 • CloudFront S3 で良いのでは?
• Lambda (Function URL) • Go 製 Web サーバー + Lambda Web Adapter
$ curl https://tsc.rip ポ ブラウザと curl でレス ンスが異なる
tsc.rip を支える技術 • AWS 静的サイト 激安 • CloudFront CloudFront Functions
で 向き先の S3 オブジェクトを 変えたら良いのでは? • Lambda (Function URL) • Go 製 Web サーバー + Lambda Web Adapter
$ curl https://tsc.rip/echo \ -XPOST -dHello ディを処理するエンド ポ ボ リクエスト
イントもある
tsc.rip を支える技術 • AWS 静的サイト 激安 • CloudFront 静的??? •
Lambda (Function URL) • Go 製 Web サーバー + Lambda Web Adapter
嘘は一つもない。どういうこと? • AWS 静的サイト 激安 • CloudFront • Lambda (Function
URL) • Go 製 Web サーバー + Lambda Web Adapter
$ curl https://tsc.rip -i X-Type-Instantiations ヘッダ???
嘘は一つもない。どういうこと? • 答え: 型レベル Web アプリケーションだったから。 リクエストのハンドリングは、すなわち「静的検査」だったのだ。
tsc.rip を支える技術 • AWS 静的サイト 激安 • CloudFront • Lambda
(Function URL) 主犯格とみられる人物 • Go 製 Web サーバー + Lambda Web Adapter
tsc.rip を支える技術 (裏) • Go 製 Web サーバー • typescript-go
を組み込み • リクエストを型に変換 → 型を評価 → 型をレス • TypeScript の型で書かれたアプリケーション ポ • export type Handle<Req> = Res; ンスに変換
型を評価する方法 • tsc のコンパイルエラーを見る • Language Server を使う • Compiler
API を使う
tsc のコンパイルエラー • 意図的に型エラーを発生させ、メッセージに含まれる型情報を抽出する • 長い型はデフォルトで省略されるが、--noErrorTruncation オプションで 回避できる • リクエストごとにプロセスを起動するので遅い
• RIP 感はある
Language Server • サブプロセスとして Language Server を起動して通信する • 長い型はデフォルトで省略されるが、オプションで回避できる (らしい)
• 今回は次の Compiler API を使ったので詳細未検討
Compiler API • サーバーにコンパイラ自体をライブラリとして組み込む • TypeScript 実装では API が公開されている •
Go 実装では (少なくとも現時点では) 非公開 (internal 以下) だが、 ハックすると無理やり使うことはできる
Compiler API // server/typeeval/go.mod // github.com/microsoft/typescript-go を自称すると internal 以下も使える module
github.com/microsoft/typescript-go/_tscrip/typeeval // ... require github.com/microsoft/typescript-go v0.0.0-20260708042240-2bd066d87f5b // typescript/v7.0.2 // server/go.mod module github.com/susisu/tsc.rip/server // ... // github.com/microsoft/typescript-go/_tscrip/typeeval は公開なので使える replace github.com/microsoft/typescript-go/_tscrip/typeeval => ./typeeval
Compiler API • Compiler API が使えるようになったが、使い方がわからない • Fable「マカセテ」 • 調査任せてたらなんかプロトタイプできたとか言ってきたので採用
型レベル Web アプリ • アプリ本体はリクエストを引数に取ってレス ンスを返す型エイリアス • export type Handle<Req>
= Res; • ルーティングやヘッダ、 ディの解釈などは基本的に全てアプリ側で実装 • Content-Length の計算など一部 Go 側に任せているものもある ートしていないので実用には向かない ポ ポ ボ • ストリームや副作用はサ
型レベル Web アプリ export type Routes<Req extends req.Request> = {
"/": { GET: (( Req["headers"] extends { accept: infer Accept extends string } ? accept.Negotiate<Accept, ["text/plain", "text/html"]> : "text/plain" ) extends "text/html" ? res.HTML<200, `<!DOCTYPE html>(略)`> : res.Text<200, "The tsc is dead, long live the tsc!\n">) & hs.Link<`<https://susisu.ch>; rel="author"`> & hs.CacheControl<"public, max-age=3600"> & hs.Vary<"accept">; }; // ... };
型レベル Web アプリ export type Handle<Req extends req.Request> = Routes<Req>
extends { [_ in Req["path"]]: infer Handlers } ? Handlers extends { [_ in Req["method"]]: infer Res } ? Res : Req["method"] extends "HEAD" ? Handlers extends { GET: infer Res } ? Res : res.Error<405, "Method Not Allowed\n"> & hs.Allow<AllowedMethods<Handlers>> : res.Error<405, "Method Not Allowed\n"> & hs.Allow<AllowedMethods<Handlers>> : res.Error<404, "Not Found\n">; type AllowedMethods<Handlers> = utils.Join< utils.UnionToTuple<"GET" extends keyof Handlers ? "HEAD" | keyof Handlers : keyof Handlers>, ", " >;
まとめ • tsc.rip の裏では型レベル Web アプリケーションが動いていた • TypeScript 万歳 •
型レベルで Web アプリケーションを書くのはおすすめしません
おまけ • https://github.com/susisu/tsserver に公開版のサーバー実装があります