docs: fix unnarrowable type predicate in plan Task 5 pipeline
mapWithConcurrency's callback return was inferred as a union of two object literal types rather than one type with deep: TDeep | undefined, so the 'entry is Pair' predicate was rejected: a type predicate's type must be assignable to its parameter's type. Added an explicit EnrichedCandidate annotation on the call. Tests passed but tsc did not, so this was only visible via typecheck. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
3d3b8ff512
commit
7b07241367
@@ -1536,8 +1536,24 @@ export async function searchPipeline<TShallow, TDeep>(
|
||||
}
|
||||
|
||||
// Phase 2: bounded enrichment.
|
||||
//
|
||||
// The explicit EnrichedCandidate annotation is required, not stylistic:
|
||||
// without it TypeScript infers the callback's return as a UNION of two
|
||||
// object literal types ({ deep: Awaited<TDeep> } | { deep: undefined })
|
||||
// rather than a single type with `deep: TDeep | undefined`. The narrowing
|
||||
// predicate below is then rejected, because a type predicate's type must be
|
||||
// assignable to its parameter's type and `Pair` is not assignable to the
|
||||
// `{ deep: undefined }` arm.
|
||||
interface EnrichedCandidate {
|
||||
candidate: TShallow;
|
||||
deep: TDeep | undefined;
|
||||
}
|
||||
|
||||
let enrichmentFailures = 0;
|
||||
const enriched = await mapWithConcurrency(selected, concurrency, async (candidate) => {
|
||||
const enriched: EnrichedCandidate[] = await mapWithConcurrency<TShallow, EnrichedCandidate>(
|
||||
selected,
|
||||
concurrency,
|
||||
async (candidate) => {
|
||||
try {
|
||||
return { candidate, deep: await spec.enrich(candidate) };
|
||||
} catch (error: unknown) {
|
||||
@@ -1547,7 +1563,8 @@ export async function searchPipeline<TShallow, TDeep>(
|
||||
enrichmentFailures++;
|
||||
return { candidate, deep: undefined };
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
interface Pair {
|
||||
candidate: TShallow;
|
||||
|
||||
Reference in New Issue
Block a user