TIL you can emulate the as const
type suffix in JS with a helper function. (source)
/**
* Identity function. Coerces string/number literals to value-as-type.
* @template {string|number} T
* @param {T} v
* @return {T}
*/
function toConst(v) {
return v;
}
const five = toConst(5);
// --> Type shows up as 5 instead of "number"