fix(features): keep the installed composers typed with two features (09-01)

flatMap over the installed-module union, the route-registry cast and the
non-distributive locale types all failed once a second feature was installed.
A unit test installs a differently shaped second feature into a copy of src
and runs the app typecheck.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-25 22:10:07 +09:00
co-authored by Claude Opus 5.5
parent 926f448fce
commit 30cf71b249
5 changed files with 151 additions and 21 deletions
+14 -4
View File
@@ -5,9 +5,18 @@ import {
} from "./feature-adapter-contribution.ts";
import { INSTALLED_PRODUCT_FEATURE_MODULES } from "./installed-product-manifest.ts";
const INSTALLED_FEATURE_ADAPTER_CONTRIBUTIONS = Object.freeze(
INSTALLED_PRODUCT_FEATURE_MODULES.flatMap((module) => module.adapters),
);
// 09-01. Indexed access distributes over the installed-module union, so this is
// every installed contribution. `flatMap` alone infers its element type from
// the first union member and rejected the second installed feature.
type InstalledFeatureAdapterContribution =
(typeof INSTALLED_PRODUCT_FEATURE_MODULES)[number]["adapters"][number];
const INSTALLED_FEATURE_ADAPTER_CONTRIBUTIONS: readonly InstalledFeatureAdapterContribution[] =
Object.freeze(
INSTALLED_PRODUCT_FEATURE_MODULES.flatMap(
(module): readonly InstalledFeatureAdapterContribution[] => module.adapters,
),
);
type InstalledFeatureCapabilityContext = ContributionsCapabilityContext<
typeof INSTALLED_FEATURE_ADAPTER_CONTRIBUTIONS
@@ -15,7 +24,8 @@ type InstalledFeatureCapabilityContext = ContributionsCapabilityContext<
/**
* Adapter installation is a projection of feature-owned descriptors. Adding a
* feature changes its descriptor and the generated index, not this composer.
* feature changes its descriptor and the generated index, not this composer
* (tests/unit/two-feature-install-typecheck.test.ts installs a second one).
*
* Q-6.9-5. The runtime composer passes `activeFeatureIds` (installed minus
* `FEATURE_OVERRIDES`). A feature switched off there gets no input, so