Skip to content

typescript: type receivers from a generic signature's T and from Record/index-signature elements - #1730

Merged
swapnilpaliwal-sd merged 1 commit into
0.1.7from
loop/ty-ts-generic-return-receiver
Sep 29, 2026
Merged

swapnilpaliwal-sd merged 1 commit into
0.1.7from
loop/ty-ts-generic-return-receiver

Conversation

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor

A receiver typed by a generic signature's result was treated as untyped:

  • pick(u).save() through pick: <T>(x: T) => T: function-type parameters now link their declared type, so T binds from the argument.
  • A signature's own <T> (function type, type-literal method/call/construct signature) is now in scope for its return.
  • Record<K, V> and inline { [k: string]: V } read by key type the element, including function-typed values (factories[kind](n).area()).

container.get<Warrior>() and Map.get already resolve when the library (the package, or the TypeScript lib) is passed with --library. They are known-missing in the client-only pass of the new case.

Checked: new case 80 with controls that stay unresolved (get<any>(), an index signature over any). TS suite 87/87 after blessing 13/73/79 (+1 correct Record edge; 2 unresolved type uses of a signature's T removed; oracle precision 1.0). Parser tests 49/49. On a real handler-map app: known edges 5→7, unresolved 5→2.

… Record/index-signature elements

A call's result was untyped when its type came from:
- a function-typed parameter with its own type parameter, bound from the
  argument: `pick: <T>(x: T) => T; pick(u).save()`. Function-type parameters
  never linked their declared type, so T had nothing to bind from;
- a signature's own `<T>` (function type, method/call/construct signature in a
  type literal), which was not in scope for its return, so `T` referenced nothing;
- a `Record<K, V>` or inline `{ [k: string]: V }` read by key, including a value
  that is itself a function type: `factories[kind](n).area()`.

Case 80 covers each shape plus controls that must stay unresolved
(`get<any>()`, an index signature over `any`).

Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com>
@swapnilpaliwal-sd
swapnilpaliwal-sd merged commit 922f405 into 0.1.7 Sep 29, 2026
12 checks passed
@swapnilpaliwal-sd
swapnilpaliwal-sd deleted the loop/ty-ts-generic-return-receiver branch September 29, 2026 01:16
@swapnilpaliwal-sd swapnilpaliwal-sd mentioned this pull request Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant