expand oparator have wrong typing
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
Expand operator have wrong typings of project function. From the description it applies the projection function to every source value as well as every output value, so the project function should receive both – input and output types.
But actually the types are implemented like this
export function expand<T, O extends ObservableInput<unknown>>(
project: (value: T, index: number) => O,
concurrent = Infinity,
scheduler?: SchedulerLike
): OperatorFunction<T, ObservedValueOf<O>>
That means i can return another type from the project function and will not receive a compilation error.
Expected behavior
The type should be like this
export function expand<T, O extends ObservableInput<unknown>>(
project: (value: T | ObservedValueOf<O>, index: number) => O,
concurrent = Infinity,
scheduler?: SchedulerLike
): OperatorFunction<T, ObservedValueOf<O>>
Reproduction code
No response
Reproduction URL
No response
Version
7.6.0
Environment
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the TypeScript declaration for the expand operator and compare its project callback type with the expected signature in the issue. Trace the operator's existing type coverage, then verify that a project function receiving both source and output value types is accepted while incompatible return types are rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100