question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Errors when parsing custom route matchers

See original GitHub issue

These are my routes for one of my modules:

const routes: Routes = [
  {
    path: '',
    component: GalleriesComponent,
    data: {
      title: 'Bildergalerien'
    }
  },
  { path: ':slug', component: GalleryComponent },
  {
    matcher: url => {
      if (url.length === 2 && url[1].path.match(/^\d+$/g)) {
        return {
          consumed: url,
          posParams: {
            slug: new UrlSegment(url[0].path, {}),
            page: new UrlSegment(url[1].path, {}),
          }
        }
      } else {
        return null
      }
    },
    component: GalleryComponent
  },
  { path: ':slug/:imageSlug', component: GalleryImageComponent },
]

This is the error I get while compodocing my app:

Unhandled Rejection at: Promise {
  <rejected> InvalidOperationError: Expected to find an initializer.
      at InvalidOperationError.BaseError [as constructor] (/Users/martin/my-project/node_modules/ts-simple-ast/dist/errors/BaseError.js:7:28)
      at new InvalidOperationError (/Users/martin/my-project/node_modules/ts-simple-ast/dist/errors/InvalidOperationError.js:8:28)
      at Object.throwIfNullOrUndefined (/Users/martin/my-project/node_modules/ts-simple-ast/dist/errors/helpers.js:96:15)
      at PropertySignature.InitializerGetExpressionableNode.class_1.getInitializerOrThrow (/Users/martin/my-project/node_modules/ts-simple-ast/dist/compiler/base/initializer/InitializerGetExpressionableNode.js:25:27)
      at RouterParserUtil.cleanFileDynamics (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:5677:80)
      at AngularDependencies.getSourceFileDecorators (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:8152:46)
      at /Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7960:31
      at Array.map (<anonymous>)
      at AngularDependencies.getDependencies (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7949:21)
      at CliApplication.Application.getDependenciesData (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:9498:40)
} reason: InvalidOperationError: Expected to find an initializer.
    at InvalidOperationError.BaseError [as constructor] (/Users/martin/my-project/node_modules/ts-simple-ast/dist/errors/BaseError.js:7:28)
    at new InvalidOperationError (/Users/martin/my-project/node_modules/ts-simple-ast/dist/errors/InvalidOperationError.js:8:28)
    at Object.throwIfNullOrUndefined (/Users/martin/my-project/node_modules/ts-simple-ast/dist/errors/helpers.js:96:15)
    at PropertySignature.InitializerGetExpressionableNode.class_1.getInitializerOrThrow (/Users/martin/my-project/node_modules/ts-simple-ast/dist/compiler/base/initializer/InitializerGetExpressionableNode.js:25:27)
    at RouterParserUtil.cleanFileDynamics (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:5677:80)
    at AngularDependencies.getSourceFileDecorators (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:8152:46)
    at /Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7960:31
    at Array.map (<anonymous>)
    at AngularDependencies.getDependencies (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:7949:21)
    at CliApplication.Application.getDependenciesData (/Users/martin/my-project/node_modules/@compodoc/compodoc/dist/application-54cd2170.js:9498:40)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

1reaction
Sebastian-Gcommented, Jun 24, 2021

It seems to relate to the tsconfig.json path definition. How did you import your Enum? In my case I could solve the issue by importing the file, without using the shorted path.

import {Role} from '@shared/models'; ➡️ import {Role} from '../shared/models';)

0reactions
stale[bot]commented, Apr 25, 2022

This issue has been automatically closed because it has not had recent activity. Please file a new issue if you are encountering a similar or related problem. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Route Matching with the Angular Router - Medium
You'll parse the URL to check if it matches the pattern you want, and you'll return the consumed URL, along with custom route...
Read more >
Tutorial: Creating custom route matches - Angular
In this tutorial, you'll build a custom route matcher using Angular's UrlMatcher . This matcher looks for a Twitter handle in the URL....
Read more >
Parser Error when deploy ASP.NET application - Stack Overflow
Once I found that one ASHX page and fixed the class name to reflect its own class name, all ASPX and ASHX files...
Read more >
Routing in ASP.NET Core - Microsoft Learn
If the routing system reported an ambiguity error at startup, ... algorithm has run out of route template to parse, so this is...
Read more >
Error handling — tapir 0.x documentation
The path doesn't match if a path segment is missing, there's a constant value mismatch or a decoding error (e.g. parsing a segment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found