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.

URLMatchResult type should include null

See original GitHub issue

🐞 bug report

Affected Package

URLMatcher is part of @angular/router

Is this a regression?

No

Description

Even in the example, is shown, that null, is to express that matcher didn’t match.

πŸ”¬ Minimal Reproduction

export function myMatcher(segments: UrlSegment[]): UrlMatchResult {
	return null;
}

πŸ”₯ Exception or Error

Type 'null' is not assignable to type 'UrlMatchResult'.

🌍 Your Environment

Angular Version:

Angular CLI: 7.1.2
Node: 9.11.1
OS: win32 x64
Angular: 7.2.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.2
@angular-devkit/build-angular     0.11.2
@angular-devkit/build-optimizer   0.11.2
@angular-devkit/build-webpack     0.11.2
@angular-devkit/core              7.1.2
@angular-devkit/schematics        7.1.2
@angular/cli                      7.1.2
@ngtools/webpack                  7.1.2
@schematics/angular               7.1.2
@schematics/update                0.11.2
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.23.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sambaptistacommented, Dec 2, 2019

This is a must have ! But in fact it already works. It seems to be just a typing issue.

myMatcher(...) : UrlMatcher // force to return non null value
myMatcher(...) // without return type, don't errors on build

The 2nd solution works as expected when returning null. The route is not activated.

It’s not β€œclean” but works.

1reaction
Akxecommented, Sep 26, 2019

I see… well then…

Read more comments on GitHub >

github_iconTop Results From Across the Web

UrlMatchResult - Angular
Represents the result of matching URLs with a custom matching function. See more... type UrlMatchResult = {Β ...
Read more >
How to consume Angulars routing UrlMatchResult from ...
I see two issues with your implementation: UrlMatchResult PosParams are not any type, they are a map of strings to UrlSegment .
Read more >
Adding and Customizing Routes - Spartacus Documentation
The CMS in SAP Commerce Cloud includes the following special page types: ... UrlSegment[] ): UrlMatchResult | null { // check if URL...
Read more >
Add navigation and routing | Getting Started with the AEM SPA ...
Dynamic navigation is implemented using Angular routes and added to an existing Header component. Objective. Understand the SPA model routingΒ ...
Read more >
Angular - UrlMatcher
type -alias. Contents. Usage notes. A function for matching a route against URLs. Implement a custom URL matcher for Route.matcher when a combination...
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