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

rxjs-5-to-6-migrate doesn't seem to handle operator chaining. #55

Open
richrd opened this issue Oct 2, 2018 · 3 comments
Open

rxjs-5-to-6-migrate doesn't seem to handle operator chaining. #55

richrd opened this issue Oct 2, 2018 · 3 comments

Comments

@richrd
Copy link

richrd commented Oct 2, 2018

I'm having issues with migrating and still have some type errors that the migrate tool didn't fix. It seems to be related to operator chaining.

BEFORE:

return this.api.request(config).map(res => {
  this.translations = JSON.parse(res.translations);
  return res;
}).share();

AFTER:

return this.api.request(config).pipe(
  map(res => {
    this.translations = JSON.parse(res.translations);
    return res;
  }))
  .share();

EXPECTED:

return this.api.request(config).pipe(
  map(res => {
    this.translations = JSON.parse(res.translations);
    return res;
  }), share());

If I understand correctly the share() in this case should be within the pipe call after map separated by a comma (as shown above). Let me know if I'm mistaken!

Here are the some of the remaining rxjs related type errors I'm getting after the migrate:

error TS2339: Property 'takeUntil' does not exist on type 'Observable<any>'.
error TS2339: Property 'debounceTime' does not exist on type 'EventEmitter<any>'.
error TS2339: Property 'first' does not exist on type 'EventEmitter<any>'.
error TS2339: Property 'share' does not exist on type 'Observable<any>'.
error TS2339: Property 'forkJoin' does not exist on type 'typeof Observable'.
error TS2339: Property 'from' does not exist on type 'typeof Observable'.
error TS2339: Property 'flatMap' does not exist on type 'Observable<any>'.
error TS2339: Property 'forkJoin' does not exist on type 'typeof Observable'.
error TS2339: Property 'from' does not exist on type 'typeof Observable'.
@capz
Copy link

capz commented Oct 8, 2018

i am surpised it updated anything other than the imports, in my case it only updated those, and left me with hundreds of errors of chained .operator calls to manually rewrite as lettable operator calls.

so it doesn't handle operator chaining well at all

@richrd
Copy link
Author

richrd commented Oct 8, 2018

For me it handled map and a few others but didn't add all the imports. I went ahead and fixed the rest of our code manually.

@kvetis
Copy link

kvetis commented Nov 11, 2019

The solution, mentioned in the readme, is to run the migrations when having version 5 of RxJS installed. If you have new version installed, downgrade it, run migrations and then install desired version again.
Readme:

Note: The rules use type checking to find all the instances of operators that need to be migrated to pipeables. This requires you to have rxjs@5 installed so that tslint could find the correct type definitions.

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

No branches or pull requests

3 participants