Property 'getRootView' does not exist on type application


#1

Hi I want add sideDrawer like in this seed https://github.com/NativeScript/template-drawer-navigation-ng
But if i add this code: openDrawer(): void { const sideDrawer = <RadSideDrawer>app.getRootView(); sideDrawer.showDrawer(); } to component for open drawer, i get error app/pages/cmp/cmp.component.ts(26,47): error TS2339: Property ‘getRootView’ does not exist on type ‘typeof “D:/Dok/app/node_modules/tns-core-modules/appli
cation/application”’.

Where is a problem?
If I look to node_modules/tns-core-module/application/application.d.ts, there is not this funciton getRootView

My dependencies:
“dependencies”: {
@angular/animations”: “~5.2.0”,
@angular/common”: “~5.2.0”,
@angular/compiler”: “~5.2.0”,
@angular/core”: “~5.2.0”,
@angular/forms”: “~5.2.0”,
@angular/http”: “~5.2.0”,
@angular/platform-browser”: “~5.2.0”,
@angular/platform-browser-dynamic”: “~5.2.0”,
@angular/router”: “~5.2.0”,
@ngrx/effects”: “^6.0.1”,
@ngrx/store”: “^6.0.1”,
@types/lodash”: “^4.14.104”,
“lodash”: “^4.17.5”,
“nativescript-angular”: “^5.2.0”,
“nativescript-contacts”: “^1.5.4”,
“nativescript-drop-down”: “^3.2.4”,
“nativescript-email”: “^1.5.2”,
“nativescript-geolocation”: “^4.2.4”,
“nativescript-google-maps-sdk”: “^2.5.0”,
“nativescript-permissions”: “^1.2.3”,
“nativescript-phone”: “^1.3.1”,
“nativescript-theme-core”: “~1.0.4”,
“nativescript-ui-chart”: “^3.5.0”,
“nativescript-ui-dataform”: “^3.5.0”,
“nativescript-ui-listview”: “^3.5.1”,
“nativescript-ui-sidedrawer”: “^3.5.1”,
“nativescript-xmlobjects”: “^1.1.4”,
“reflect-metadata”: “~0.1.8”,
“rxjs”: “^6.1.0”,
“rxjs-compat”: “^6.1.0”,
“tns-core-modules”: “~3.4.0”,
“zone.js”: “~0.8.2”
},

and in package-lock: “tns-core-modules”: {
“version”: “3.4.1”,
“resolved”: “https://registry.npmjs.org/tns-core-modules/-/tns-core-modules-3.4.1.tgz”,
“integrity”: “sha512-sz/yTmoW7WyDPpr4JEC+trlfiEI14X365jGF//tMCT/G6ISzANr43wc17fgbGH1UA1XbKzujbAl0xPNssRHVUA==”,
“requires”: {
“tns-core-modules-widgets”: “3.4.0”
}
},


#2

The root-view functionaility is available since NativeScript 4. You are using tns-core-modules 3.x.y.
Try upgrading to NS 4 and try again.

Make sure to read the first part of this post:
https://www.nativescript.org/blog/nativescript-4.0-is-out


#3

And How I can update it?

Now I create app from this template: https://github.com/NativeScript/template-drawer-navigation-ng from master:
:tns create my-drawer-ng --template https://github.com/NativeScript/template-drawer-navigation-ng

But I get that error too.
Yea i have version 3.4.2:
nativescript │ 3.4.2 │ 4.1.0 │ Update available │
│ tns-core-modules │ 3.4.1 │ 4.1.0 │ Update available │
│ tns-android │ 3.4.2 │ 4.1.1 │ Update available
But How i update it?


#4

Actually you just need to:

npm install -g nativescript@latest

… to install the latest nativescript-cli version. Then you need to do:

tns platform remove android
tns platform remove ios

tns plugin add tns-core-modules@latest

tns run

#5

Oh thanks, it works

But now I get errors from rxjs:

app/user/user.service.ts(17,26): error TS2304: Cannot find name ‘Observable’.

app/login.service.ts(2,10): error TS2305: Module ‘app/node_modules/rxjs/BehaviorSubject"’ has no exported member ‘BehaviorSubject’.

node_modules/rxjs/BehaviorSubject.d.ts(1,15): error TS2307: Cannot find module ‘rxjs-compat/BehaviorSubject’.

node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module ‘rxjs-compat/Observable’.


#6

Use RxJS 5.x, 6.x has completely changed the internal structure and will break your app.


#7

Ok thanks.
I write to package.json verion ~5.5.5 and remove platform and nodemodules ant run tns run android
But now I get this error:
JS: bootstrap: rxjs.merge is not a function
JS:
JS: TypeError: rxjs.merge is not a function
JS: at new ApplicationRef (file:///data/data/org.nativescript.App/files/app/tns_modules/@angular/core/bundles/core.umd.js:5053:18)
JS: at _createClass (file:///data/data/org.nativescript.App/files/app/tns_modules/@angular/core/bundles/core.umd.js:9356:20)
JS: at createProviderInstance$1 (file:///data/data/org.nativescript.App/files/app/tns_modules/@angular/core/bundles/core.umd.js:9318:26)
JS: at initNgModule (file:///data/data/org.nativescript.App/files/app/tns_modules/@angular/core/bundles/core.umd.js:9254:32)
JS: at new NgModuleRef
(file:///data/data/org.nativescript.App/files/app/tns_modules/@angular/core/bundles/core.umd.js:9983:9)
JS: at createNgModuleRef (file:///data/data/org.nativescript.App/files/app/tns_modules/@angular/core/bundles/core.umd.js:9972:12)
JS: at Object.debugCreateNgModuleRef [as createNgModuleRef] (file:///data/data/org.nativescript.App

And while building I get note: node_modules/@angular/common/src/location/location.d.ts(1,10): error TS2305: Module ‘“App/node_modules/rxjs/Rx”’ has no exported member ‘SubscriptionLike’.


#8

You are using Angular 5.x only right?


#9

No 6.x which were set it https://github.com/NativeScript/template-drawer-navigation-ng

Here is package json:
“dependencies”: {
@angular/animations”: “~6.0.0”,
@angular/common”: “~6.0.0”,
@angular/compiler”: “~6.0.0”,
@angular/core”: “~6.0.0”,
@angular/forms”: “~6.0.0”,
@angular/http”: “~6.0.0”,
@angular/platform-browser”: “~6.0.0”,
@angular/platform-browser-dynamic”: “~6.0.0”,
@angular/router”: “~6.0.0”,
“nativescript-angular”: “~6.0.0”,
“nativescript-contacts”: “^1.5.4”,
“nativescript-email”: “^1.5.2”,
“nativescript-geolocation”: “^4.2.6”,
“nativescript-phone”: “^1.3.1”,
“nativescript-theme-core”: “~1.0.4”,
“nativescript-ui-dataform”: “^3.6.0”,
“nativescript-ui-sidedrawer”: “~4.1.0”,
“nativescript-xmlobjects”: “^1.1.4”,
“reflect-metadata”: “~0.1.10”,
“rxjs”: “~5.5.5”,
“tns-core-modules”: “^4.1.0”,
“zone.js”: “~0.8.18”
},


#10

Or If you can write me please from which version of https://github.com/NativeScript/template-drawer-navigation-ng should I create app, which will be separate to module, will be compatibable with some version of rxjs, use tns-core-modules 4.1? And I want use ngrx in the app.
Thanks


#11

I assumed you are using Angular 5.x based on your first post. If you are using Angular 6.x, You must use rxjs 6.x only.

But remember none of the old imports will work, the internal file structure is completely changed. Refer it’s official documentation to know whats changed and how to handle them. Also you must make sure all your dependencies supports rxjs 6.x.

In case if any of your dependency don’t support rxjs 6.x yet / you really want the old code and import statements to work, you must install rxjs-compat as dependency.

That was exactly your error earlier :point_up:


#12

On Begin I used https://github.com/NativeScript/template-drawer-navigation-ng with angular 5.x with only one app.module.
But then I want change app with separate modules and use ngrx, so i change files and version and it broke.

So I try create new app by https://github.com/NativeScript/template-drawer-navigation-ng with angular with angular 5,x. But i get error with old version tns-core-module

But felix-idf wrote that i need nativescript 4, I didnt know how update it so I create new app from master template where is angular 6 and I thing with nativescript 4. But there were others error with rxjs.
So I create new app with angular6 from https://github.com/NativeScript/template-drawer-navigation-ng master.

But now I am totally lost in versions.

But now i thing right, that I can update nativescript version(tns-core-module) out of my app using npm install -g nativescript@latest and tns plugin add tns-core-modules@latest?

So should I use master of sidedrawer with angular 6 (and which version of rxjs use?), or create again new app on stable version with angular 5.x?
And nativescript can I update separate of app using this: npm install -g nativescript@latest?

Or I can use angular 6 change rxjs to 6 and install rxjs-compat v6.x ?

Thanks for your help


#13

{N} 4.0 uses Angular 5.3, but {N} 4.1 is where they start supporting for Angular 6.x. If you want to stick to latest of everything, go with the last approach you mentioned.