fix(frontend): resolve svelte-check type errors
- vite-mock-plugin: define the missing MockFile type and annotate the MOCK_FILES / MOCK_TRASH arrays so restore (unshift) type-checks. - categories/[id], tags/[id]: page.params.id is string | undefined under noUncheckedIndexedAccess — guard loadTags and default the TagRuleEditor tagId so the routes type-check. svelte-check now reports 0 errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,8 @@
|
|||||||
void loadTags(id, 0);
|
void loadTags(id, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function loadTags(id: string, startOffset: number) {
|
async function loadTags(id: string | undefined, startOffset: number) {
|
||||||
|
if (!id) return;
|
||||||
tagsLoading = true;
|
tagsLoading = true;
|
||||||
try {
|
try {
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
|
|||||||
@@ -172,7 +172,7 @@
|
|||||||
<!-- Tag rules -->
|
<!-- Tag rules -->
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<h2 class="section-title">Implied tags</h2>
|
<h2 class="section-title">Implied tags</h2>
|
||||||
<TagRuleEditor {tagId} {rules} onRulesChange={(r) => (rules = r)} />
|
<TagRuleEditor tagId={tagId ?? ''} {rules} onRulesChange={(r) => (rules = r)} />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -114,6 +114,24 @@ function mockThumbSvg(id: string): string {
|
|||||||
</svg>`;
|
</svg>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MockFile = {
|
||||||
|
id: string;
|
||||||
|
original_name: string;
|
||||||
|
mime_type: string;
|
||||||
|
mime_extension: string;
|
||||||
|
content_datetime: string;
|
||||||
|
notes: string | null;
|
||||||
|
metadata: unknown;
|
||||||
|
exif: Record<string, unknown>;
|
||||||
|
phash: number | null;
|
||||||
|
creator_id: number;
|
||||||
|
creator_name: string;
|
||||||
|
is_public: boolean;
|
||||||
|
is_deleted: boolean;
|
||||||
|
created_at: string;
|
||||||
|
position?: number;
|
||||||
|
};
|
||||||
|
|
||||||
// Trash — pre-seeded with a few deleted files
|
// Trash — pre-seeded with a few deleted files
|
||||||
const MOCK_TRASH: MockFile[] = Array.from({ length: 6 }, (_, i) => {
|
const MOCK_TRASH: MockFile[] = Array.from({ length: 6 }, (_, i) => {
|
||||||
const mimes = ['image/jpeg', 'image/png', 'image/webp'];
|
const mimes = ['image/jpeg', 'image/png', 'image/webp'];
|
||||||
@@ -139,7 +157,7 @@ const MOCK_TRASH: MockFile[] = Array.from({ length: 6 }, (_, i) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const MOCK_FILES = Array.from({ length: 75 }, (_, i) => {
|
const MOCK_FILES: MockFile[] = Array.from({ length: 75 }, (_, i) => {
|
||||||
const mimes = ['image/jpeg', 'image/png', 'image/webp', 'video/mp4'];
|
const mimes = ['image/jpeg', 'image/png', 'image/webp', 'video/mp4'];
|
||||||
const exts = ['jpg', 'png', 'webp', 'mp4' ];
|
const exts = ['jpg', 'png', 'webp', 'mp4' ];
|
||||||
const mi = i % mimes.length;
|
const mi = i % mimes.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user