Production code (all findings cleared):
- GenerationHistory: drop unused fetchProHistory(userId) param,
change let activeId to const
- InitiativeTracker: remove write-only currentSessionName state
- NotesPanel: remove unused isLoading flag
- Open5eReference: drop unused getCachedTranslation/setCachedTranslation
imports; use fetchTranslation result directly instead of re-lookup
- ai/openrouter.ts: drop unused z + Monster imports; attach cause to
rethrown AbortError
- ai/kimi.ts: drop unused z import
- api/dm/ai/generate.ts: annotate best-effort counter increment catch
- api/dm/ai/history.ts: drop unused sql import
Test files (trivial fixes; ~70 mock-related `as any` errors remain as
pre-existing tech debt across api test mocks):
- translation-client: drop unused MockBroadcastChannel _name param and
unused getCachedTranslation destructure
- open5e-types: eslint-disable for the intentional type-test aliases
- {notes,initiative}-api: remove unused mockUser2 placeholder
- {notes,initiative,translate,history}-api: let mockDb -> const mockDb
- ai-generate-api: wrap deliberate `var` mock decls in eslint-disable
with comment explaining vi.mock hoisting requirement
Verification: tsc 0 errors, vitest 339/339, lint 81 -> 70 errors
(production code fully clean; remaining errors are test-mock as-any
patterns from Waves 5-6).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import type { Monster, Spell } from "../src/lib/open5e/client";
|
|
|
|
// Type-level assertions: verify interfaces contain all required fields.
|
|
// If a listed key is missing from the interface, TypeScript will error at compile time.
|
|
type AssertKeys<T, K extends keyof T> = K;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
type _MonsterHasAllFields = AssertKeys<
|
|
Monster,
|
|
| "name"
|
|
| "key"
|
|
| "challenge_rating_decimal"
|
|
| "type"
|
|
| "hit_points"
|
|
| "armor_class"
|
|
| "speed"
|
|
| "actions"
|
|
| "special_abilities"
|
|
| "legendary_actions"
|
|
| "senses"
|
|
| "languages"
|
|
| "strength"
|
|
| "dexterity"
|
|
| "constitution"
|
|
| "intelligence"
|
|
| "wisdom"
|
|
| "charisma"
|
|
| "size"
|
|
| "subtype"
|
|
| "alignment"
|
|
| "damage_immunities"
|
|
| "damage_resistances"
|
|
| "damage_vulnerabilities"
|
|
| "condition_immunities"
|
|
>;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
type _SpellHasAllFields = AssertKeys<
|
|
Spell,
|
|
| "name"
|
|
| "key"
|
|
| "level"
|
|
| "school"
|
|
| "casting_time"
|
|
| "range"
|
|
| "components"
|
|
| "duration"
|
|
| "desc"
|
|
| "higher_level"
|
|
| "ritual"
|
|
| "concentration"
|
|
| "classes"
|
|
>;
|
|
|
|
// Runtime dummy test so Vitest recognizes this file.
|
|
describe("Open5e type assertions", () => {
|
|
it("Monster interface contains all required keys at compile time", () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
|
|
it("Spell interface contains all required keys at compile time", () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
});
|