Not ideal, but one option is to reconstruct an object with the checked type:
function typecheck<T extends Language>(code: Code<T>) {
const { lang, content } = code;
if (lang === "TYPESCRIPT") {
typecheckTS({ lang, content });
} else {
// ...
}
}