Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
tsc.rip を支える技術 / Kyoto.なんか #8
Search
Susisu
August 22, 2026
Programming
70
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
250
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
2.3k
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
susisu
7
2.8k
君だけのオリジナル async / await を作ろう / TSKaigi 2025
susisu
20
16k
null or undefined
susisu
25
7.9k
Mackerel のフロントエンドフレームワーク移行 序章 / Hatena Engineer Seminar #13
susisu
0
2.3k
スクリーンショット撮影のために Puppeteer を操る / Kyoto.js 16
susisu
0
1k
BuckleScript 使ってみた
susisu
0
430
Atom パッケージ開発のすゝめ
susisu
1
2.3k
Other Decks in Programming
See All in Programming
30年振りにコンパイラの定数整数除算を改善した
herumi
3
770
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
6.7k
リアルな遅延を測る仕様
kota_yata
1
120
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
330
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
350
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
170
AIを紡ぐPMのお話
swdtkuy
0
120
バグを直したら useEffect が消えた
colorful12
3
660
typoなんかねぇよ
raspython3
0
100
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
0
200
プロポーザルを書いてもらう
pvcresin
0
560
SlackアプリとLambdaの 連携を構築した話
pawn_4_s
1
130
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Designing for Timeless Needs
cassininazir
1
450
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
180
Utilizing Notion as your number one productivity tool
mfonobong
4
550
Designing Experiences People Love
moore
143
24k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
300
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
550
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Faster Mobile Websites
deanohume
310
32k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
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 に公開版のサーバー実装があります