angular icon indicating copy to clipboard operation
angular copied to clipboard

fix(core): Improve DebugElement.query() return type

Open JeanMeche opened this issue 2 years ago • 2 comments

DebugElement.query() can return null, let's reflect that on the return type. This commit also provides a migration to insert non-null assertions after DebugElement.query() on existing code bases.

Fixes #22449

PR Type

What kind of change does this PR introduce?

  • [x] Feature

Does this PR introduce a breaking change?

  • [x] Yes, should target the next major.

JeanMeche avatar Feb 01 '23 23:02 JeanMeche

How can I run the new migration schematic on the angular project itself ?

Edit: I did it with a regex, but still I would interested how to do that !

JeanMeche avatar Feb 02 '23 12:02 JeanMeche

For reference, there was previous conversation around whether it would be better to throw an error rather than return null. https://github.com/angular/angular/pull/39632#issuecomment-1031774045 Returning null aligns with document.querySelector and has an easier migration.

I think this should be marked as a fix rather than a feature.

atscott avatar Feb 04 '23 00:02 atscott

I'm going through my old PR, I believe this one will shift to at least v17, right ?

JeanMeche avatar May 01 '23 14:05 JeanMeche

I'm going through my old PR, I believe this one will shift to at least v17, right ?

Yes, I've added it to the v17-candidates milestone.

AndrewKushnir avatar May 02 '23 00:05 AndrewKushnir

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.