
* Type fixes * Uses all integrations and session fixes on getting started page * eventtype form fixes * Update pages/event-types/[type].tsx Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
23 lines
599 B
TypeScript
23 lines
599 B
TypeScript
export function asStringOrNull(str: unknown) {
|
|
return typeof str === "string" ? str : null;
|
|
}
|
|
|
|
export function asStringOrUndefined(str: unknown) {
|
|
return typeof str === "string" ? str : undefined;
|
|
}
|
|
|
|
export function asNumberOrUndefined(str: unknown) {
|
|
return typeof str === "string" ? parseInt(str) : undefined;
|
|
}
|
|
|
|
export function asNumberOrThrow(str: unknown) {
|
|
return parseInt(asStringOrThrow(str));
|
|
}
|
|
|
|
export function asStringOrThrow(str: unknown): string {
|
|
const type = typeof str;
|
|
if (type !== "string") {
|
|
throw new Error(`Expected "string" - got ${type}`);
|
|
}
|
|
return str;
|
|
}
|