Backwards compatibility with angular 7 wrt `static` view queries
See original GitHub issueSo with the the latest angular 8.0.0-rc.5, a breaking change was included where @ViewChild
must define a static
option.
In the latest angular 7 release (7.2.15) this option does not exist, causing a typescript error during compilation.
Imho this change is unacceptable for library authors. I have a private component library where i cannot force everyone to upgrade to angular 8 all at once. My plan was to change the peerDependencies
to "@angular/core": "^7.0.0 || ^8.0.0",
, but with the static
option breaking change i cannot do that.
I suppose one workaround is to “cast” the options type to any, but i’d rather not do that since that way the typescript compiler might miss bugs.
@ViewChild('scroller', { static: true } as any) scroller: ElementRef<HTMLElement>;
Other options may be to release a new angular 7 patch version that includes the static
option, but does nothing with it (a NOOP)? But at least that way it will compile?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7 (3 by maintainers)
@jpzwarte thanks for the report and for confirming that v7 apps will continue to work with you library in spite of the static flag. All of this is working as expected.
We spent the last few days going over all the scenarios and looking for the path to make this query fix as easy on everyone as possible. We do not take this breaking change lightly but we also don’t want the old very buggy behavior to proliferate any longer because it is making application developers lives miserable (there are many bugs open due to the old behavior).
This is why we decided to make this change in v8 and request that everyone specifies the query resolution behavior explicitly rather that depends on a magical behavior. The automated migration via ng update should greatly assist with the transition and the fact that this doesn’t break v7 libs also helps.
One note: if your goal is to make you Liv compatible with v7 and v8 then you shouldn’t update your job at all (except for peerDependencies in package.json). If you do update and start reactivate your app to take advantage of the new v8 apis or dependencies (ts, RxJS, etc), you will be making your lib incomparable with v7 apps.
For this reason the simplest thing to do to support apps is for libraries to adopt 6 month major version schedule and bump their major after each Angular update. That way the libs are in the same release cadence as Angular and we are safely and clearly communicating versioning requirements to the app developers.
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.