ReactiveX / ReactiveX/rxjs

Add generic parameter to `AjaxResponse` and `ajax`

Open
#5,600 6 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
31.7k
Forks
3k
PR merge metrics
No merged PRs in 30d

Description

Feature Request

Is your feature request related to a problem? Please describe.
ajax(params) returns Observable<AjaxResponse> with field response typed as any.

Describe the solution you'd like
I'd like to be able to pass generic parameter to ajax, like:

ajax<{ field: string }>(params).pipe(map({ response: { field } }) => field))  // properly inferred as `Observable<string>`

Describe alternatives you've considered
Casting type each time, repetitive and annoying.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the TypeScript declarations and tests for AjaxResponse and ajax, then inspect how the current response field is typed and inferred. The work is done when callers can provide a generic response shape and the resulting observable infers that shape without repetitive casts, with existing behavior preserved.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.