【エラーメッセージ】
TS2707 [ERROR]: Generic type 'RouterContext<R, P, S>' requires between 1 and 3 type arguments.
Deno や TypeScript が日々進化していることが理由なのか、ネットで拾ったコードが大体このエラーになる。ジェネリクスの引数を渡さないまま使っていることが原因。
解決策✨
インポート文を修正して、RouterContextを上書きで定義する
修正前.ts
import { Application, Router, RouterContext } from "https://deno.land/x/oak/mod.ts";
↓
修正後.ts
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
import type { RouterContext as XContext } from "https://deno.land/x/oak/mod.ts";
type RouterContext = XContext<any, any, any>;
すると、それ以降のコードはそのまま使えるようになる。
any 型を使いたくない人はもう少し工夫が必要になるけど、とりあえず動くところまで。