Nativescript-angular: Nativescript-Angular 10: Can't import NSRouteReuseStrategy

Created on 7 Sep 2020  路  7Comments  路  Source: NativeScript/nativescript-angular

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 7.0.6
  • Cross-platform modules: 7.0.0
  • Android Runtime: -
  • iOS Runtime: 7.0.0
  • Plugin(s): -
  • NativeScript-Angular: ~10.1.0
  • Angular: ~10.1.0

Describe the bug
We have successfully used a custom Route Reuse Startegy in a Nativescript Project pre version 7. After upgrading to the latest version (see environment) it is not possible to build and run the app anymore.
When following the upgrade instructions here https://nativescript.org/blog/angular-10-support/ we updated all imports from nativescript-angular/{anything} to @nativescript/angular. This resulted in the following import import {NSRouteReuseStrategy} from "@nativescript/angular"; which throws an error during compilation:

ERROR in src/app/custom-route-reuse.ts:3:9 - error TS2305: Module '"../../node_modules/@nativescript/angular/nativescript-angular"' has no exported member 'NSRouteReuseStrategy'.

3 import {NSRouteReuseStrategy} from "@nativescript/angular";

and gets also marked by the Typescript Linter because NSRouteReuseStrategyis simply not exported.

We then changed the import to import {NSRouteReuseStrategy} from "@nativescript/angular/router/ns-route-reuse-strategy"; which prevents linting errors but throws the following error during compilation:

ERROR in ./app/custom-route-reuse.ts
Module not found: Error: Can't resolve '@nativescript/angular/router/ns-route-reuse-strategy' in '/Users/.../route-reuse-test/src/app'
 @ ./app/custom-route-reuse.ts 2:0-92 5:46-66
 @ ./app/app.module.ts
 @ ./main.ts

To Reproduce
Create a clean new project with ns createusing Nativescript 7 and Nativescript-Angular 10 and then try to add a Custom Route Reuse Strategy.
Alternatively check out and run https://github.com/lukas-eschstruth/route-reuse-test

Expected behavior
There is valid export/import for the NSRouteReuseStrategy class.

Sample project
https://github.com/lukas-eschstruth/route-reuse-test

Most helpful comment

@bmacdonald @lukas-eschstruth published in ~10.1.6 now, could you try it and lemme know if you have any other issue.

All 7 comments

@lukas-eschstruth

Did you ever get a fix for this issue? I am encountering the same problem.

I鈥檓 going to bump out a patch with another pr this morning and will make sure that symbol is exported - will ping back here when it goes out.

@NathanWalker awesome, was about to sit down and see if I could do it myself, but that's great to hear. I will check it as soon as it's available

@NathanWalker
Thanks for the response. I pushed it in slack, but it seems you beat my response here.

@bmacdonald @lukas-eschstruth published in ~10.1.6 now, could you try it and lemme know if you have any other issue.

@NathanWalker
The following import is working correctly now.

import { NSRouteReuseStrategy } from '@nativescript/angular';

Thank you for taking care of this. There is another issue, but I need to spend time debugging. I do not think it is related to the issue you fixed.

Ok thanks for confirming - I'll close this but if something else comes up feel free to open another 馃憤

Was this page helpful?
0 / 5 - 0 ratings