Visitar URL original
refactor(core): handle #24571 todos. by JeanMeche · Pull Request #49221 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20250601060642/https://github.com/angular/angular/pull/49221
Skip to content

refactor(core): handle #24571 todos. #49221

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

Closed
wants to merge 1 commit into from

Conversation

JeanMeche
Copy link
Member

@JeanMeche JeanMeche commented Feb 26, 2023 •

This commit removes the remaining TODO(issue/24571) in core code base.

In the core code base most TODOs were on spec files where it is acceptable to have non-null assertions.

See also the PRs about #24571 :

*#48241

@@ -217,7 +217,8 @@ export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChan
}

this._truncate(record);
(this as {collection: V[] | Iterable<V>}).collection = collection;
// @ts-expect-error overwriting a readonly member
this.collection = collection;
Copy link
Member Author

@JeanMeche JeanMeche Feb 26, 2023 •

Choose a reason for hiding this comment

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

Using @ts-expect-error instead of a type assertion improves the code navigation.

Copy link
Member Author

@JeanMeche JeanMeche Jun 6, 2023 •

Choose a reason for hiding this comment

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

Few month have passed, I actually want to push for using the Writable type, cf #49754

@JeanMeche JeanMeche force-pushed the chore/coore-24571 branch 2 times, most recently from fbc23b6 to 6f4f4ca Compare February 26, 2023 23:37
@@ -32,7 +32,7 @@ const trackByIdentity = (index: number, item: any) => item;
*/
export class DefaultIterableDiffer<V> implements IterableDiffer<V>, IterableChanges<V> {
public readonly length: number = 0;
// TODO(issue/24571): remove '!'.
// TODO: confirm the usage of `collection` as it's unused, readonly and on a non public API.
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it could removed in separate PR with a move of DefaultIterableDiffer to the private space.

Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

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

@JeanMeche thnx for the PR and sorry that it took so much time to process.

I've went through 1/2 of it and I would love to discus the usage of ! for @Input fields.

Generally my thinking is that inputs (and other non-query fields) would be better off with a default value or adding undefined to the type.

My reasoning is that queries are assigned by the framework and the author of the component has full control over assign timing / usage. With @Inputs (and other fields) there are no guarantees.

It doesn't matter the whole lot but people often look at Angular tests for examples / "inspiration" so we should decide on the pattern here.

WDYT?

@@ -1489,7 +1483,6 @@ describe(`ChangeDetection`, () => {
class MyChild {
private thrown = LifetimeMethods.None;

// TODO(issue/24571): remove '!'.
@Input() inp!: boolean;

Choose a reason for hiding this comment

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

boolean|undefined? or inp = false?

changes!: SimpleChanges;
event: any;
eventEmitter: EventEmitter<string> = new EventEmitter<string>();

// TODO(issue/24571): remove '!'.
@Input('testDirective') name!: string;

Choose a reason for hiding this comment

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

Generally my thinking is that inputs (and other non-query fields) would be better off with a default value or adding undefined to the type.

My reasoning is that queries are assigned by the framework and the author of the component has full control over assign timing / usage. With @Inputs (and other fields) there are no guarantees.

It doesn't matter the whole lot in this particular case but people often look at Angular tests for examples / "inspiration" so we should decide on the pattern here.

Copy link
Member Author

Choose a reason for hiding this comment

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

You last argument nails it for me. Every bit a code that is accessible to the devs should be of the highest standards !
I will update the PR.

@pkozlowski-opensource pkozlowski-opensource added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 6, 2023
@JeanMeche JeanMeche force-pushed the chore/coore-24571 branch 3 times, most recently from cc9d18f to a18c887 Compare June 7, 2023 08:00
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: fw-core
Reviewed-for: fw-security

@pkozlowski-opensource pkozlowski-opensource added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release 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 Jun 7, 2023
@dylhunn dylhunn self-requested a review June 10, 2023 01:02
Copy link
Contributor

@dylhunn dylhunn left a comment

Choose a reason for hiding this comment

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

Needs one more fw-security approval. Perhaps @josephperrott can provide the stamp? It's basically a no-op in that regard.

Copy link
Member

@alxhub alxhub 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: fw-security

@alxhub alxhub removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Jun 12, 2023
@pkozlowski-opensource pkozlowski-opensource added the action: merge The PR is ready for merge by the caretaker label Jun 13, 2023
@pkozlowski-opensource
Copy link
Member

@JeanMeche it looks like this PR will need a rebase after the recent merges of your other PR :-)

@pkozlowski-opensource pkozlowski-opensource 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 Jun 14, 2023
This commit removes the remaining TODO(issue/24571) in core code base.
@JeanMeche JeanMeche force-pushed the chore/coore-24571 branch from a18c887 to 9a770e6 Compare June 14, 2023 09:08
@JeanMeche
Copy link
Member Author

@pkozlowski-opensource There you go ! You can merge it now =)

@pkozlowski-opensource pkozlowski-opensource removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jun 14, 2023
@pkozlowski-opensource
Copy link
Member

Thnx @JeanMeche !

@pkozlowski-opensource pkozlowski-opensource added action: presubmit The PR is in need of a google3 presubmit and removed action: presubmit The PR is in need of a google3 presubmit labels Jun 14, 2023
@pkozlowski-opensource
Copy link
Member

This PR was merged into the repository by commit 8d42747.

pkozlowski-opensource pushed a commit that referenced this pull request Jun 14, 2023
This commit removes the remaining TODO(issue/24571) in core code base.

PR Close #49221
@JeanMeche JeanMeche deleted the chore/coore-24571 branch June 27, 2023 21:26
@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 Jul 28, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
This commit removes the remaining TODO(issue/24571) in core code base.

PR Close angular#49221
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: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants