lazarljubenovic / ng-morph

Angular AST analyzer and manipulator.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Routes resolver allows only literals for `path`.

lazarljubenovic opened this issue · comments

In my route definition, I have this.

{
  path: TopLevelRoutePaths.Users,
  loadChildren: () => import('../users/users.module').then(m => m.UsersModule),
},

And elsewhere:

export enum TopLevelRoutePaths {
  Users = 'users',
}

This currently breaks because it expects a literal, but this should be replaced with some sort of resolver that attempts to statically analyze and build the string.

The problem here is not to get too carried away and actually implement it better than Angular's compiler currently does (sorry Tobias). So for now just add resolving to a simple const path = 'users' or using enumerations like in the example above.