Add typecheck

This commit is contained in:
2025-08-21 00:17:01 +02:00
parent 79c900955d
commit 5d1a029a54
12 changed files with 44 additions and 24 deletions
+1
View File
@@ -1,3 +1,4 @@
// @ts-expect-error weird bun import with nuxt
import { describe, expect, it } from 'bun:test';
import { checkSlug, parseSlug, type SlugRecord } from './slugcheck';
+8 -7
View File
@@ -1,4 +1,4 @@
import type { RouteParamsGeneric } from '#vue-router';
import type { RouteParamsGeneric } from 'vue-router';
export type Slug = { name: string; id: number };
export type SlugRecord = Record<string, Slug>;
@@ -16,12 +16,13 @@ export function parseSlug(slug: string): null | Slug {
const { name, id } = result.groups!;
return {
name: name
.substring(0, name.length - 1)
.split('-')
.map((w) => `${w.substring(0, 1).toUpperCase()}${w.substring(1)}`)
.join(' '),
id: parseInt(id)
name:
name
?.substring(0, name.length - 1)
.split('-')
.map((w) => `${w.substring(0, 1).toUpperCase()}${w.substring(1)}`)
.join(' ') ?? '',
id: parseInt(id!)
};
}