8

I have an Angular 5 project which has many modules and hundreds of components. Since RxJs 6 you have to use

someObservable.pipe(map(...))

instead of

someObservable.map(...)

I want to migrate this project from Angular 5 to 6, but dont want to change every occurrence of .map() by hand.

The Angular update side suggests

rxjs-5-to-6-migrate -p src/tsconfig.app.json

for migrating to rxjs 6, but I am afraid that this can't change my code.

Any suggestions on how to save time and change from .map() to .pipe(map()) automatically?

10
  • 1
    Are you sure the migration command doesn't work for you? I tried it in one of my projects and it did a solid job. The obvious workaround would be to do a find and replace yourself. Commented May 11, 2018 at 12:44
  • @enf0rcer If I rerun the command: 'Cannot find any possible migrations'. Did the migrationtool change your code to the new layout? Would be a good clue if the tool is actually capable to do that. Commented May 11, 2018 at 12:46
  • Yes it did, I'm not sure about the map method though. But it surely changed imports and stuff like that. Commented May 11, 2018 at 12:49
  • 2
    I checked it for you, the GitHub page mentions it is able to help you out "to some extent": github.com/ReactiveX/rxjs/blob/master/MIGRATION.md Commented May 11, 2018 at 12:54
  • 1
    @David Bulté's answer should work, but first you have to revert changes made with initial running of the command. I needed to do the same and it worked for me perfectly. Commented Jul 12, 2018 at 21:12

1 Answer 1

5

Maybe this can help?

I followed all steps in https://update.angular.io/, but somehow at the end of chain I had the same problem you have: all my rxjs imports were changed, but the operators hadn't been changed to pipeable operators.

Then I noticed that the rxjs-compat package hadn't been installed (due to https://github.com/angular/angular-cli/issues/10631?). After installing rxjs-compat manually (npm install rxjs-compat --save) and running rxjs-5-to-6-migrate -p src/tsconfig.app.json again, the pipes appeared!

Sign up to request clarification or add additional context in comments.

1 Comment

Hmm no doesn't work for me. My map function still stay the same. The command executes and returns "Cannot find any possible migrations"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.