ReviewOS

home-lang/home

fix(ts): infer generic async projection callback results

#476
Closed chris opened this 8 days ago ·
8 days ago

Follow-up to #473 and #416. Identical strict/noEmit/noLib/skipLibCheck/ES2022 project plus unchanged TS 6.0.3 Promise/PromiseLike declarations. Both pinned TS 6.0.3 and native TS 7.0.2 accept the following, but Home reports TS2322 at label: Type '{ then: any; }' is not assignable to type 'string'.

declare function load<T>(value: T): PromiseLike<T>;
async function mapAsync<T, U>(input: PromiseLike<T>, project: (value: T) => U | PromiseLike<U>): Promise<U> {
  return project(await input);
}
async function use(input: { label: string }) {
  const mapped = await mapAsync(load(input), value => value.label);
  const label: string = mapped;
}

Investigate callback inference and generic substitution/awaiting without weakening the U | PromiseLike signature or supplying explicit type arguments to the benchmark. Add positive and wrong-result-type controls, including callbacks returning actual PromiseLike values. Async remains outside the timed suite until this and the other #473 semantic controls pass. Small conventional commits linked to these issues.

8 days ago

Closing as completed by 65f80a5 (fix(ts): infer async projection callback results (#476)). Current main retains a permanent regression stronger than the original report: expression and block callbacks, direct values and real PromiseLike-returning callbacks, exact Promise<string> results, awaited string consumers, and four deliberate wrong-result controls. Fresh verification on 0ae8024: the focused guarded checker target passed 2/2 (compile peak 1,759 MB, host low-water 37%). The identical fixture under pinned TypeScript 6.0.3 and native TypeScript 7.0.2 produced exactly the same four TS2322 diagnostics at the same lines; Home also reports exactly four type_not_assignable diagnostics with the same string-to-number message. No duplicate code change was made merely to close a stale issue.

Sign in to comment on this issue.