`fromPromise(p, c => defect(c))` infers `Defect` into the error channel (should be `never`)
Summary
When a fromPromise / fromThrowable qualify function returns only defect(cause) (i.e. every rejection is unmodeled), the resulting AsyncResult's error channel is inferred as Defect rather than never — so the opaque Defect marker type leaks into E and pollutes downstream combinator types.
Repro
import { fromPromise, defect, type Result, type AsyncResult } from "unthrown";
// helper that wraps a Result-producing thunk, routing unexpected throws to defects
function makeAsyncResult<T, E>(work: () => Promise<Result<T, E>>): AsyncResult<T, E> {
// ❌ Type 'AsyncResult<T, E | Defect>' is not assignable to type 'AsyncResult<T, E>'
return fromPromise(work, (cause) => defect(cause)).flatMap((inner) => inner);
}
fromPromise(work, (c) => defect(c)) is inferred as AsyncResult<Result<T,E>, Defect> (the qualify return type E | Defect collapses to Defect because nothing constrains E), and .flatMap then widens to E | Defect.
Expected
A qualify that only ever returns defect(...) should infer the modeled error type as never, yielding AsyncResult<T, never> — a defect is out-of-band and shouldn't appear in E.
Workaround
fromSafePromise(work) does exactly this (error channel never, rejections → defect), and is the right primitive here. But the fromPromise(..., () => defect(...)) footgun is easy to reach for and the resulting type error (E | Defect not assignable to E) points at the wrong place.
Suggestion
Either an overload / better inference so a defect-only qualify yields E = never, or a doc note steering "all rejections are defects" usage to fromSafePromise.
Found while migrating temporal-contract to unthrown (btravstack/temporal-contract#263).