fix(help): correct broken imports + tighten SupportedLanguage typing

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) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-09 18:13:18 +02:00
parent b32de06f2a
commit 9bf73fffa3
11 changed files with 22 additions and 13 deletions

View file

@ -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: [

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { ChangelogEntryProps } from '../types.js';
import type { ChangelogEntryProps } from '../ui-types';
let { item, translations }: ChangelogEntryProps = $props();

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { ChangelogSectionProps } from '../types.js';
import type { ChangelogSectionProps } from '../ui-types';
import ChangelogEntry from './ChangelogEntry.svelte';
let { items, translations, maxItems = 10 }: ChangelogSectionProps = $props();

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { ContactSectionProps } from '../types.js';
import type { ContactSectionProps } from '../ui-types';
let { contact, translations }: ContactSectionProps = $props();
</script>

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { FAQItem } from './content';
import type { FAQItem } from '../content';
interface Props {
item: FAQItem;

View file

@ -1,6 +1,6 @@
<script lang="ts">
import type { FAQItem, FAQCategory } from './content';
import type { FAQSectionProps } from '../types.js';
import type { FAQItem, FAQCategory } from '../content';
import type { FAQSectionProps } from '../ui-types';
import FAQItemComponent from './FAQItem.svelte';
let {

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { FeatureItem } from './content';
import type { FeatureItem } from '../content';
interface Props {
item: FeatureItem;

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { FeaturesOverviewProps } from '../types.js';
import type { FeaturesOverviewProps } from '../ui-types';
import FeatureCard from './FeatureCard.svelte';
let { items, translations }: FeaturesOverviewProps = $props();

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { GettingStartedGuideProps } from '../types.js';
import type { GettingStartedGuideProps } from '../ui-types';
let { items, translations }: GettingStartedGuideProps = $props();

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { HelpSearchProps } from '../types.js';
import type { HelpSearchProps } from '../ui-types';
import type { SearchResult } from '../content';
import { createSearcher } from '../search-engine';

View file

@ -1,5 +1,5 @@
<script lang="ts">
import type { KeyboardShortcutsProps } from '../types.js';
import type { KeyboardShortcutsProps } from '../ui-types';
let { items, translations }: KeyboardShortcutsProps = $props();