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): Correct type of nextState parameter in canDeactivate #48038

Closed
wants to merge 1 commit into from

Conversation

JeanMeche
Copy link
Member

@JeanMeche JeanMeche commented Nov 12, 2022

Correct type of nextState parameter in canDeactivate guard to indicate it's never undefined

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?

on canDeactivate(), nextState is always provided, there was no need to make it an optional parameter.

Issue Number: #47153

Does this PR introduce a breaking change?

  • Yes
  • No

@ngbot ngbot bot added this to the Backlog milestone Nov 14, 2022
@AndrewKushnir AndrewKushnir requested review from atscott and removed request for AndrewKushnir November 14, 2022 18:58
@AndrewKushnir AndrewKushnir added the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 14, 2022
@atscott
Copy link
Contributor

atscott commented Nov 14, 2022

I would consider this a fix rather than a refactor. So the commit message should read "fix(router): correct type of nextState parameter in canDeactivate guard to indicate it's never undefined".

I'm not sure if we need to consider this a breaking change, but I would expect that we do. I would bet there are tests for guards which manually pass in mocks for the parameter values that would break due to this change.

@JeanMeche
Copy link
Member Author

@atscott fix is fine for me.

About the breaking changes, this PR breaks the internal tests, so yeah it's breaking something.

@JeanMeche JeanMeche changed the title refactor(router): Make nextState parameter canDeactivate required fix(router): Correct type of nextState parameter in canDeactivate Nov 14, 2022
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@JeanMeche thanks for the PR, I've left a couple minor comments. It'd be great to remove any unrelated changes (removals of new lines, adding semicolons, etc) from this PR, so that it only contains the changes that are needed. You can create a followup PR if there are some formatting changes that you'd like to propose. Thank you.

packages/router/src/models.ts Outdated Show resolved Hide resolved
packages/router/src/models.ts Outdated Show resolved Hide resolved
@AndrewKushnir AndrewKushnir added the target: major This PR is targeted for the next major release label Nov 14, 2022
@AndrewKushnir AndrewKushnir modified the milestones: Backlog, v16-candidates Nov 14, 2022
@JeanMeche JeanMeche force-pushed the feature/fix-47153 branch 2 times, most recently from 394dfaf to 2b369d9 Compare November 14, 2022 20:12
@JeanMeche
Copy link
Member Author

@AndrewKushnir done ✅

@atscott
Copy link
Contributor

atscott commented Nov 15, 2022

About the breaking changes, this PR breaks the internal tests, so yeah it's breaking something.

It looks like I was wrong about it being a breaking change. We can do this and implementors can still have nextState?: RouterStateSnapshot and it'll pass the build. So this looks like a safe change to make.

@atscott atscott added target: patch This PR is targeted for the next patch release and removed target: major This PR is targeted for the next major release labels Nov 15, 2022
Correct type of nextState parameter in canDeactivate guard to indicate it's never undefined

Fixes angular#47153
@JeanMeche
Copy link
Member Author

JeanMeche commented Nov 15, 2022

@atscott I push the changes for CanDeactivateFn

Copy link
Contributor

@atscott atscott left a comment

Choose a reason for hiding this comment

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

reviewed-for: public-api

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@atscott atscott added target: rc This PR is targeted for the next release-candidate action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer target: rc This PR is targeted for the next release-candidate labels Nov 15, 2022
@dylhunn
Copy link
Contributor

dylhunn commented Nov 17, 2022

This PR was merged into the repository by commit b51929a.

dylhunn pushed a commit that referenced this pull request Nov 17, 2022
…8038)

Correct type of nextState parameter in canDeactivate guard to indicate it's never undefined

Fixes #47153

PR Close #48038
@dylhunn dylhunn closed this in b51929a Nov 17, 2022
@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 Dec 18, 2022
@JeanMeche JeanMeche deleted the feature/fix-47153 branch January 4, 2023 22:58
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
…gular#48038)

Correct type of nextState parameter in canDeactivate guard to indicate it's never undefined

Fixes angular#47153

PR Close angular#48038
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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants