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
feat(router): add type properties to all router events #44189
Conversation
5427cf2
to
1b177dc
Compare
d26e936
to
30c8187
Compare
|
Tnx a lot for this PR, will help us a lot in our use case |
All router events now have a `type` property with a string name identifying the specific type of the event. The `type` property can be used to perform TypeScript type narrowing using an `if` statement, `switch` statement, or similar. This removes the need to perform `instanceof` checks but still allows them if preferred. An `instanceof` check requires the use of the event class value which may not be available or preferred in certain situations. The Router's `enableTracing` option is also now guarded with the `ngDevMode` flag which combined with the use of a new `stringifyEvent` function allows the tree-shaking of the string generation code for each router event class. However, the original `toString` class methods are still present to prevent a potential breaking change. As a result, full benefits of the tree-shaking potential will not be realized until they are removed.
|
Awesome, presubmit looks green. Lmk when you are ready for merge. |
|
merge assistance: pullapprove is down. This has all necessary approvals |
|
Moving to v14.1 candidates. Global presubmit revealed a lot more work needs to be done to resolve failures there. We'll also need to make a decision on whether this needs to be considered breaking based on how many failures there were. |
|
merge assistance: There is one outstanding fix in g3 that needs approval from a team in the European timezone. Please merge this at the very end and maybe wait until tomorrow to sync it to g3. |
|
Removing merge assistance. The CL is now submitted. This is good to go. |
|
This PR was merged into the repository by commit 41e2a68. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |




All router events now have a
typeproperty with a string name identifying the specific type of the event. Thetypeproperty can be used to perform TypeScript type narrowing using anifstatement,switchstatement, or similar. This removes the need to performinstanceofchecks but still allows them if preferred. Aninstanceofcheck requires the use of the event class value which may not be available or preferred in certain situations.