Files
Hankan/types/lib/conjugation.d.ts
MechaCat02 966043ab3f feat(lib): type declarations and golden tests for the exported modules
lib/ ships unchanged, so its types live in types/lib/ and are wired up by a
tsconfig path mapping. Adding types costs nothing; reimplementing the logic
would cost the two things that make this port possible.

The tests exist so a later refactor cannot silently drift them:

  hangul       the nine Composer cases named in the export README —
               먹어 · 왔어 · 읽어 · 괜찮아 · 값 · 의사 · 뭐야 and backspace
  conjugation  all seven irregular classes, and every form in
               IRREGULAR_FORMS reachable through haeche()
  srs          the SM-2 transitions, ease and interval clamps
  blocks       parse → answerText round-trip for all four task types

101 tests.

One is a pinned defect rather than a guarantee. blocks.parse() never closes
a ::gloss block on its "=" line, so a multi-sentence gloss — which the tutor
prompt explicitly invites — collapses into one run-on line keeping only the
last translation. lib/ ships unchanged, so the test records the real
behaviour and the app works around it at the call site.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 19:12:19 +02:00

34 lines
1.2 KiB
TypeScript

/* Declarations for lib/conjugation.js — the module itself ships unchanged. */
/** Forms that do not fall out of the rules and are simply known. */
export const IRREGULAR_FORMS: Record<string, string>;
/** Dictionary form → 반말 present (해체). Returns null for non-verbs. */
export function haeche(dict: string): string | null;
/** 반말 present → 반말 past. 먹어 → 먹었어. */
export function past(present: string | null): string | null;
export function polite(present: string | null): string | null;
export type IrregularClass =
| "ㅡ" | "ㅂ" | "ㄷ" | "르" | "ㅅ" | "ㅎ" | "special" | "regular";
/** Which class a dictionary form belongs to — drives the "why" in feedback. */
export function irregularClass(dict: string): IrregularClass;
/** Human explanation of the rule applied — shown when an answer is wrong. */
export function explain(dict: string): string;
export interface SurfaceForm {
form: string;
gloss: string;
note: string;
}
/**
* Build-time: every surface form a learner will meet, mapped back to its lemma.
* This is what replaces a runtime morphological analyser.
*/
export function surfaceForms(dict: string, gloss: string): SurfaceForm[];