Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected startWith types behaviour inside pipe #4013

Closed
OliverJAsh opened this issue Aug 14, 2018 · 2 comments
Closed

Unexpected startWith types behaviour inside pipe #4013

OliverJAsh opened this issue Aug 14, 2018 · 2 comments

Comments

@OliverJAsh
Copy link
Contributor

Bug Report

Current Behavior
When using startWith inside of pipe, the argument type is not validated and/or the return type may be incorrect.

Reproduction

import { of } from 'rxjs';
import { startWith } from 'rxjs/operators';
import 'rxjs/Rx';

const ob2$ = of(1).startWith(
    // Expect error, got one :-)
    // Argument of type '"foo"' is not assignable to parameter of type 'number | SchedulerLike'.
    'foo',
);

const ob$ = of(1).pipe(
    startWith(
        // Expected error, but got none :-(
        'foo',
    ),
);
// OR, if we don't get an error, we should at least get a union:
// $ExpectType Observable<number | string>
// but got actual type Observable<{}>
ob$;

Expected behavior
When using startWith inside of pipe, I would expect either:

  • the argument type must match the Observable's inner type
  • the return type should be a union of the Observable's inner type and the argument type

Environment

  • Runtime: no runtime, purely type level
  • RxJS version: 6.2.2

Possible Solution

Additional context/Screenshots
Related #2544

@cartant
Copy link
Collaborator

cartant commented Aug 14, 2018

This looks like it's the same problem that was reported in #3841 and fixed in #3945.

@OliverJAsh
Copy link
Contributor Author

Amazing, thanks @cartant. I'll wait for the next release.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants