From 9bf73fffa346cacd1a08429c844b9470dc9f391f Mon Sep 17 00:00:00 2001 From: Till JS Date: Thu, 9 Apr 2026 18:13:18 +0200 Subject: [PATCH] fix(help): correct broken imports + tighten SupportedLanguage typing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two unrelated bugs in the @mana/help package surface that together accounted for ~40 type errors: Broken component imports Ten components inside packages/help/src/components/ were importing from `'../types.js'` and `'./content'` — neither path resolves. The actual files are at `../ui-types` (where FAQSectionProps, FeaturesOverviewProps etc. live) and `../content` (where FAQItem, FeatureItem, FAQCategory live). Fix the imports to point at the real files. ESM resolution doesn't need `.js` suffixes when TypeScript is feeding tsc, and the existing index.ts already re-exports under the correct paths. Net: -19 type errors across: ChangelogEntry, ChangelogSection, ContactSection, FAQItem, FAQSection, FeatureCard, FeaturesOverview, GettingStartedGuide, HelpSearch, KeyboardShortcuts content/help/index.ts SupportedLanguage cast `getManaHelpContent()` was passing `currentLocale` (typed `string`) into FAQ rows that expect a `SupportedLanguage` enum — 9 errors from each FAQ row. Add a small `asSupportedLanguage()` guard that validates the locale string against the union and falls back to 'de' for unknown values. Single source of truth lives next to the function that needed it. Net: -9 type errors. Combined with the spiral-db dist rebuild (local-only, gitignored) and the previous Observable migration commit, the total error count drops from 418 → 115. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/mana/apps/web/src/lib/content/help/index.ts | 13 +++++++++++-- packages/help/src/components/ChangelogEntry.svelte | 2 +- .../help/src/components/ChangelogSection.svelte | 2 +- packages/help/src/components/ContactSection.svelte | 2 +- packages/help/src/components/FAQItem.svelte | 2 +- packages/help/src/components/FAQSection.svelte | 4 ++-- packages/help/src/components/FeatureCard.svelte | 2 +- .../help/src/components/FeaturesOverview.svelte | 2 +- .../help/src/components/GettingStartedGuide.svelte | 2 +- packages/help/src/components/HelpSearch.svelte | 2 +- .../help/src/components/KeyboardShortcuts.svelte | 2 +- 11 files changed, 22 insertions(+), 13 deletions(-) diff --git a/apps/mana/apps/web/src/lib/content/help/index.ts b/apps/mana/apps/web/src/lib/content/help/index.ts index 8e1f26dda..8f53af6f4 100644 --- a/apps/mana/apps/web/src/lib/content/help/index.ts +++ b/apps/mana/apps/web/src/lib/content/help/index.ts @@ -2,7 +2,7 @@ * Help content for Mana app — reads from i18n locale files. */ -import type { HelpContent } from '@mana/help'; +import type { HelpContent, SupportedLanguage } from '@mana/help'; import { getPrivacyFAQs } from '@mana/help'; import { get } from 'svelte/store'; import { _, locale } from 'svelte-i18n'; @@ -11,8 +11,17 @@ function t(key: string): string { return get(_)(key) || key; } +const SUPPORTED: readonly SupportedLanguage[] = ['en', 'de', 'fr', 'it', 'es']; + +function asSupportedLanguage(loc: string | null | undefined): SupportedLanguage { + if (loc && (SUPPORTED as readonly string[]).includes(loc)) { + return loc as SupportedLanguage; + } + return 'de'; +} + export function getManaHelpContent(loc?: string): HelpContent { - const currentLocale = loc || get(locale) || 'de'; + const currentLocale = asSupportedLanguage(loc || get(locale)); return { faq: [ diff --git a/packages/help/src/components/ChangelogEntry.svelte b/packages/help/src/components/ChangelogEntry.svelte index 642faf8f7..7ed80a684 100644 --- a/packages/help/src/components/ChangelogEntry.svelte +++ b/packages/help/src/components/ChangelogEntry.svelte @@ -1,5 +1,5 @@ diff --git a/packages/help/src/components/FAQItem.svelte b/packages/help/src/components/FAQItem.svelte index 7bc782688..7e40820e5 100644 --- a/packages/help/src/components/FAQItem.svelte +++ b/packages/help/src/components/FAQItem.svelte @@ -1,5 +1,5 @@