2.6 KiB
2.6 KiB
Tasks: i18n-spec-conformance-followup
1. Engine .parse() wiring
- 1.1 Replace hand-written option validation in
MessageCatalog,InterpolationEngine,LocaleResolverconstructors with*Schema.safeParse(options). Schemas extended with.passthrough()and structural slots for function-valued fields (formatters/defaultFormatter/onMissingKey/backend(s)) so existing call sites pass. - 1.2 Map Zod failures to
I18nError(<relevant code>, ..., { context: { zodIssues } }):I18N.INVALID_OPTIONSfor catalog;I18N.INTERPOLATION_ERRORfor interpolation;I18N.INVALID_LOCALEfor resolver. - 1.3 Swept in-repo consumers — only
src/conformance.test.ts::"constructor throws INVALID_OPTIONS on missing fallback"needed updating (renamed toINVALID_LOCALEand asserts the newzodIssuescontext payload).
2. Generic t<K> / get<K> migration
- 2.1 Narrowed
MessageCatalog.t,.get,.has,.tPluraltoK extends DotPaths<TMessages> | (string & {})(theDotPathstype and type-level test already shipped ini18n-spec-conformance). - 2.2 Existing in-repo consumers all pass
stringkeys (noTMessagestyped catalogs in repo yet); the(string & {})escape hatch keeps every call site compiling unchanged. - 2.3 The
dot-paths.test.tstype-level test continues to assert the generic shape;expectTypeOfcontinues to pass after the runtime narrowing.
3. Property/benchmark layout
- 3.1 Moved
packages/i18n/i18n/tests/property.test.ts→ four files underpackages/i18n/i18n/tests/properties/(flatten-record.test.ts,normalize-locale.test.ts,html-escape.test.ts,build-key.test.ts) — one file per property cluster inI18N-13. - 3.2 Split
packages/i18n/i18n/src/__benchmarks__/i18n.bench.tsintocatalog.bench.ts,interpolation.bench.ts,pluralization.bench.ts. Updated thebenchpackage script to chain all three. - 3.3 Re-publish baseline numbers in
README.mdafter first green bench run. (Out of scope for this commit — no perf regression risk; tracked for the next user-driven bench run.)
4. Verify
- 4.1
bunx turbo lint typecheck test --filter=@suaveplan/i18ngreen. - 4.2
bunx turbo test:coverage --filter=@suaveplan/i18n100/100/100/100. - 4.3
bunx turbo build --filter=@suaveplan/i18ngreen. - 4.4 STOP before publish — user approves before
bun scripts/publish.ts --package @suaveplan/i18n.
5. Archive
- 5.1 No spec delta folded — the change clears carry-forwards (no new requirements).
- 5.2 Move
openspec/changes/i18n-spec-conformance-followup/→openspec/archive/2026-05-05-i18n-spec-conformance-followup/.