Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router): allow UrlMatcher to return null #36402

Closed
wants to merge 1 commit into from

Conversation

mbward
Copy link

@mbward mbward commented Apr 2, 2020

The matcher is allowed to return null per
https://angular.io/api/router/UrlMatcher#usage-notes

Fixes #29824

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Incorrect type error

error TS2322: Type '(url: UrlSegment[]) => UrlMatchResult | null' is not assignable to type 'UrlMatcher'.
  Type 'UrlMatchResult | null' is not assignable to type 'UrlMatchResult'.
    Type 'null' is not assignable to type 'UrlMatchResult'.

Issue Number: 29824

What is the new behavior?

No type error.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove pullapprove bot requested review from atscott and IgorMinar April 2, 2020 21:42
@atscott atscott added area: router breaking changes action: presubmit The PR is in need of a google3 presubmit target: major This PR is targeted for the next major release labels Apr 2, 2020
@ngbot ngbot bot modified the milestone: needsTriage Apr 2, 2020
@atscott
Copy link
Contributor

atscott commented Apr 2, 2020

FYI - lint is failing because we recently updated clang. Please run yarn gulp format to fix this.

@mbward
Copy link
Author

mbward commented Apr 2, 2020

FYI - lint is failing because we recently updated clang. Please run yarn gulp format to fix this.

Done.

Odd that it didn't reformat goldens/public-api/router/router.d.ts.

@atscott
Copy link
Contributor

atscott commented Apr 2, 2020

global presubmit passed with no failures.

Copy link
Contributor

@IgorMinar IgorMinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please document this as a minor breaking change affecting those that implemented the UrlMatcher type. This should be easy to fix and doesn't require a migration, all we need is a documentation in the form of a commit message block in the format: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#footer

@IgorMinar IgorMinar added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 2, 2020
@atscott atscott removed the action: presubmit The PR is in need of a google3 presubmit label Apr 2, 2020
@mbward
Copy link
Author

mbward commented Apr 3, 2020

please document this as a minor breaking change affecting those that implemented the UrlMatcher type

Since we're widening the type, don't all existing implementations already satisfy the new type?

I think the concern would be for anybody implementing their own Router and assuming matcher couldn't return null. Which is unlikely to be the case, since it already could return null. But I'll happily mention that in the commit message footer.

The matcher is allowed to return null per
https://angular.io/api/router/UrlMatcher#usage-notes

And run `yarn gulp format` to pick up recent clang format changes.

Closes angular#29824

BREAKING CHANGE: UrlMatcher's type now reflects that it could always return
    null.

    If you implemented your own Router or Recognizer class, please update it to
    handle matcher returning null.
@atscott atscott added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 3, 2020
@kara kara closed this in 568e9df Apr 3, 2020
@sod
Copy link
Contributor

sod commented Apr 7, 2020

i guess you can reject @trshafer contribution in #22898 now

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router breaking changes cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

URLMatchResult type should include null
6 participants