UNPKG

354 BPlain TextView Raw
1import type { OneRouter } from './interfaces/router'
2
3/**
4 * Type-level utility function to help pass valid Href typed strings.
5 * Does not actually validate at runtime, though we could add this later.
6 */
7export function href<A extends OneRouter.Href>(a: A): A {
8 if (!a || typeof a !== 'string') {
9 throw new Error(`Invalid href`)
10 }
11 return a
12}