angular
angular copied to clipboard
fix(core): Improve DebugElement.query() return type
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.
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 !
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.
I'm going through my old PR, I believe this one will shift to at least v17, right ?
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.
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.