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.

Backwards compatibility with angular 7 wrt `static` view queries

See original GitHub issue

So 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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
IgorMinarcommented, May 24, 2019

@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.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 15, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Static query migration guide - Angular
If your goal is to make your library compatible with Angular versions 7 and 8, you should not update your lib at all...
Read more >
Why is Angular 2 not backwards compatible with AngularJS?
Angular 2 is not coupled deeply with the DOM and has its own renderer. Therefore View manipulations are easier and faster. Routing is...
Read more >
Getting Out of Version-Mismatch-Hell with Module Federation
There might be cases where you know that a higher major version is backward compatible even though it doesn't need to be with...
Read more >
Correct way to package an Angular library to support Angular ...
This incompatibility happens basically due to a change at the internal workings of Angular compilation. So, since this is possibly a breaking ...
Read more >
Angular-schema-form-dynamic-select NPM | npm.io
Check Angular -schema-form-dynamic-select 0.13.1 package - Last release 0.13.1 with MIT licence at our NPM packages aggregator and search engine.
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