Skip to content

refactor(common): remove non-null assertions from directives - #48476

Closed
JeanMeche wants to merge 4 commits into
angular:mainfrom
JeanMeche:feature/fix-24571-directives
Closed

JeanMeche wants to merge 4 commits into
angular:mainfrom
JeanMeche:feature/fix-24571-directives

Conversation

@JeanMeche

Copy link
Copy Markdown
Member

PR Checklist

Per request from @pkozlowski-opensource, I'm splitting PR #48241 into 2.

See individual commits.

These are fixes targeted to resolve #24571

PR Type

What kind of change does this PR introduce?

  • Refactoring (no functional changes, no api changes)

Does this PR introduce a breaking change?

  • No

@pullapprove
pullapprove Bot requested a review from atscott December 13, 2022 17:22
@JeanMeche
JeanMeche force-pushed the feature/fix-24571-directives branch from 097c8e5 to 5d844ce Compare December 13, 2022 17:45

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would _switchValue be better with a default value? It's actually kind of correct with the ! right now. The directive won't match unless this is defined. It's a little unfortunate that we have to add code to account for the possibility of undefined when it really can't ever be in production.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You're right, we can keep the type safety by passing the value to _updateView

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this have a default of empty array instead of undefined?

@JeanMeche JeanMeche Dec 21, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd rather see undefined or null as a default value. It's created when needed by _addDefault and checked by _updateDefaultCases.

I'm always to other point of views though !

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having it be nullable rather than empty list provides no additional meaning. I feel quite strongly that this should never be null or undefined. You can also update the rest of the code to remove the truthiness checks of this value.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I used empty array as default value. It seems presubmit is failing now with the changes. Any heads-up ?

@jessicajaniuk jessicajaniuk added the area: common Issues related to APIs in the @angular/common package label Dec 13, 2022
@ngbot ngbot Bot added this to the Backlog milestone Dec 13, 2022
@JeanMeche
JeanMeche force-pushed the feature/fix-24571-directives branch 3 times, most recently from a6014c4 to 2478c77 Compare December 21, 2022 22:39

@atscott atscott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 LGTM

@JeanMeche
JeanMeche force-pushed the feature/fix-24571-directives branch from 2478c77 to ea115c8 Compare December 27, 2022 17:52
As part of angular#24571, removing all non-null assertions from common/directives
@JeanMeche
JeanMeche force-pushed the feature/fix-24571-directives branch 5 times, most recently from aa2afb1 to b883f2a Compare December 27, 2022 19:18
@JeanMeche
JeanMeche requested a review from atscott December 27, 2022 19:19

@atscott atscott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@JeanMeche looks like the lint test is failing. The code changes otherwise look good and the internal test failures are unrelated

@JeanMeche
JeanMeche force-pushed the feature/fix-24571-directives branch from b883f2a to 4e03ca3 Compare December 29, 2022 16:38
@angular-robot
angular-robot Bot requested a review from atscott December 29, 2022 16:38
As part of angular#24571, removing all non-null assertions from common/directives
* removing guard as console.warn is now widely supported
* Couldn't remove non-null assertion, waiting for TS support of getters with different types (microsoft/TypeScript#43662)
As part of angular#24571, removing all non-null assertions from common/test/directives
@JeanMeche
JeanMeche force-pushed the feature/fix-24571-directives branch from 4e03ca3 to 51bd989 Compare December 29, 2022 16:40
@JeanMeche

Copy link
Copy Markdown
Member Author

@JeanMeche looks like the lint test is failing. The code changes otherwise look good and the internal test failures are unrelated

Done.

@atscott atscott added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jan 5, 2023
@alxhub

alxhub commented Jan 5, 2023

Copy link
Copy Markdown
Member

This PR was merged into the repository by commit d887d69.

alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/directives

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/directives

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
* removing guard as console.warn is now widely supported
* Couldn't remove non-null assertion, waiting for TS support of getters with different types (microsoft/TypeScript#43662)

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/test/directives

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/directives

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/directives

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
* removing guard as console.warn is now widely supported
* Couldn't remove non-null assertion, waiting for TS support of getters with different types (microsoft/TypeScript#43662)

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/test/directives

PR Close #48476
@alxhub alxhub closed this in 559f518 Jan 5, 2023
alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/directives

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
* removing guard as console.warn is now widely supported
* Couldn't remove non-null assertion, waiting for TS support of getters with different types (microsoft/TypeScript#43662)

PR Close #48476
alxhub pushed a commit that referenced this pull request Jan 5, 2023
As part of #24571, removing all non-null assertions from common/test/directives

PR Close #48476
@JeanMeche
JeanMeche deleted the feature/fix-24571-directives branch January 7, 2023 01:33
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
As part of angular#24571, removing all non-null assertions from common/directives

PR Close angular#48476
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
As part of angular#24571, removing all non-null assertions from common/directives

PR Close angular#48476
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
* removing guard as console.warn is now widely supported
* Couldn't remove non-null assertion, waiting for TS support of getters with different types (microsoft/TypeScript#43662)

PR Close angular#48476
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
As part of angular#24571, removing all non-null assertions from common/test/directives

PR Close angular#48476
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 Feb 7, 2023
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: common Issues related to APIs in the @angular/common package target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post strictPropertyInitialization flag flip cleanup

4 participants