type Types = 'string' | 'number' | 'boolean' | 'object' type TypeMap = { string: string number: number boolean: boolean object: object } export function isType(type: T): (v: unknown) => v is TypeMap[T] { return (v: unknown): v is TypeMap[T] => typeof v === type }