Update to 4.1 and rxjs imports are all broken


#1

In my Nativescript app using angular I ran tns update and now I cannot compile. It appears all of my rxjs imports are broken. I’m getting lots of errors:

pp/core/services/http.service.ts(32,10): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.

app/core/services/http.service.ts(39,10): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
app/core/services/http.service.ts(47,10): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.

and later down:

pp/core/services/http.service.ts(135,14): error TS2339: Property 'do' does not exist on type 'Observable<Object>'.

app/core/services/notes.service.ts(10,10): error TS2305: Module '"/Users/brice/source/class2tns/node_modules/rxjs/Observable"' has no exported member 'Observable'.

app/core/services/notes.service.ts(64,10): error TS2339: Property 'flatMap' does not exist on type 'Observable<Object>'.
app/core/services/notes.service.ts(92,10): error TS2339: Property 'flatMap' does not exist on type 'Observable<Object>'.

app/core/services/player.service.ts(2,10): error TS2305: Module '"/Users/brice/source/class2tns/node_modules/rxjs/Observable"' has no exported member 'Observable'.
app/core/services/player.service.ts(4,10): error TS2305: Module '"/Users/brice/source/class2tns/node_modules/rxjs/observable/interval"' has no exported member 'interval'.

I can’t seem to find good instructions for updating to 4.1. Does anyone have a link for me?


#2

basically every api is changed in rxjs6, you should put every operations in pipe() function.


#3

It’s not actually {N} 4.1 but rxjs 6. You will have to refactor your code with pipe and use proper import statements.

Here is a quick video what & how you should do


#4

Yeah, that was a big move. It took me a couple of hours to switch my .map pipes, flatMap, switchMap and forkJoins throughout my code. I saw on the rxjs site a lot of the changes were to fix issues related to reserved keywords in javascript.

One {N} thing I also had to change was:

from

latformNativeScriptDynamic().bootstrapModule(AppModule);

to


enableProdMode();
platformNativeScriptDynamic({ createFrameOnBootstrap: true }).bootstrapModule(AppModule);

I hope this helps if anyone else is migrating to 4.1