fix(features): check declared needs and show the IndexedDB capability assembly (09-05)
A missing capability reached the feature factory as an anonymous TypeError. The composer now names the feature and the capability, and the IndexedDB provider example moves from a browser spec into an opt-in recipe with a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
30cf71b249
commit
bc7c46b2d5
@@ -174,6 +174,20 @@ export function composeFeatureAdapterInputs<
|
||||
}
|
||||
seen.add(contribution.featureId);
|
||||
if (!enabled.has(contribution.featureId)) continue;
|
||||
// 09-05. The context type already asks for every declared need, but a
|
||||
// host that widens it (or JavaScript) used to reach the feature's factory
|
||||
// and fail there as an anonymous TypeError.
|
||||
const provided = context as Readonly<
|
||||
Partial<Record<FeaturePlatformCapabilityId, unknown>>
|
||||
>;
|
||||
const missing = contribution.needs.find(
|
||||
(need) => provided[need] === undefined,
|
||||
);
|
||||
if (missing !== undefined) {
|
||||
throw new TypeError(
|
||||
`feature ${contribution.featureId} needs ${missing}, which the host did not provide`,
|
||||
);
|
||||
}
|
||||
|
||||
const installed = invokeContribution(
|
||||
contribution as unknown as FeatureAdapterContribution<
|
||||
|
||||
Reference in New Issue
Block a user