question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add default/optional parameters to support easy upgrade on ViewChild/ContentChild breaking changes

See original GitHub issue

🚀 feature request

Relevant Package

This feature request is for @angular/core

Description

we have a large application with large number of references to ViewChild/ContentChild decorators. with latest v8 these decorators are modified with breaking change to include {static: true/false} parameter. can we make this as a optional/default parameter so we do not have to make large set of changes across our application and depended libraries. (we do use depended libraries which also reference ViewChild/ContentChild and it will be really hard to migrate all the depended libraries to new format)

Describe the solution you’d like

Make {static: true/false} parameter optional or use default value = false.

Describe alternatives you’ve considered

we are considering alternative to use @ViewChild('foo', <any>{static: false}) on all our existing v7 codebase to mitigate the upgrade complexity (still not tested or finalized). but we are still blocked on doing same steps in libraries we are depending on (not in our control).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
trotylcommented, Sep 20, 2019

If I look into the code I can read that this was expected to be optional

That’s true, it should definitely be optional, and that’s already happening: https://github.com/angular/angular/pull/32582, https://github.com/angular/angular/pull/32686, https://github.com/angular/angular/pull/32720

Making it required in v8 and optional again v9 is for warning about this breaking change, as the fallback behavior in v7 and v9 are different.

2reactions
mlakmalcommented, May 30, 2019

Make {static: true/false} parameter optional or use default value = false.

Making any static default value will also become breaking change, as the previously runtime has a dynamic default value based on usage, which is worse as not even awared by user.

i was not aware of this being dynamic earlier. yes it will not be ideal (unless we have it like before by default) but user will have option to override based on their requirement.

at-least having default/optional value would allow us to start progressing on upgrade validation instead of being blocked on this issue (since this breaks, and not being able to update external library code we are now blocked until all dependencies are corrected).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Static query migration guide
In version 9, the default setting for @ViewChild and @ContentChild queries is changing in order to fix buggy and surprising behavior in queries...
Read more >
ViewChild in *ngIf - angular
I have a component with its contents hidden by default. When someone calls show() method it becomes visible. However, before Angular 2 change...
Read more >
Angular 8 Upgrade Guide (Material, ViewChild/ContentChild ...
Angular 8 Upgrade Guide (Material, ViewChild / ContentChild, etc)Here's how we can upgrade our project to Angular 8!
Read more >
Angular ng-content and Content Projection
In this post, we are going to learn how to use this feature to design components that have a very simple but still...
Read more >
Heading Off 11 Common Angular Application Design, Best ...
ContentChild has some additional restrictions to ViewChild in the types of selectors that can be used. It only supports Component or Directive types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found