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.

Versioning of Angular between Angular Applications and Angular Libraries

See original GitHub issue

Description

I’m getting an error when I compile an angular library that uses a different version of Angular than the library it’s including.

Please provide the steps to reproduce the issue

Create an Angular application in which your package.json has

"dependencies": {
    "@angular/forms": "^11",
}

Create an Angular library in which your package.json has

"dependencies": {
     "@angular/forms": "^11.2.12"
}

Then link the application to the library with ng link Compile the application with with ng build.

Please provide the expected behavior vs the actual behavior you encountered

I would prefer to know can an application be versioned newer than a library? Can a library be versioned newer than the application it’s compiled in? Or do all Angular things (applications and libraries) need to have the same version?

It would be nice to have a better warning and documentation on this.

Please provide the exception or error you saw

Error: src/app/components/forms/forms.component.ts:48:54 - error TS2345: Argument of type 'ValidatorFn' is not assignable to parameter of type 'ValidatorFn | ValidatorFn[] | AbstractControlOptions'.
  Type 'import("/root/libs/angular-validators/node_modules/@angular/forms/forms").ValidatorFn' is not assignable to type 'import("/root/demo-app/node_modules/@angular/forms/forms").ValidatorFn'.
    Types of parameters 'control' and 'control' are incompatible.
      Type 'import("/root/demo-app/node_modules/@angular/forms/forms").AbstractControl' is not assignable to type 'import("/root/libs/angular-validators/node_modules/@angular/forms/forms").AbstractControl'.
        Types have separate declarations of a private property '_parent'.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, Oct 26, 2021

In terms of compatibility:

I would prefer to know can an application be versioned newer than a library? Can a library be versioned newer than the application it’s compiled in? Or do all Angular things (applications and libraries) need to have the same version?

We try to ensure that Angular applications can use libraries that are versioned up to 2 major versions prior to the version of the application. (But in practice, you can usually go much further back than that - there are a number of libraries that are built with v8, for example, that work fine with v12 applications).

We do not officially support an application using a library that was built with a newer version of Angular than the application. So if your application is built with Angular v11, then all the libraries it depends upon ought to be built with v11 or earlier. This actually also includes minor versions, but not patch versions. (Again, in practice, you may well be able to get away with using a library with a newer version, although v13 has a hard break in this regards since it is not possible to consume v13 libraries with ViewEngine applications).

0reactions
angular-automatic-lock-bot[bot]commented, Nov 30, 2021

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

Creating libraries - Angular
The Angular version used to build an application should always be the same or greater than the Angular versions used to build any...
Read more >
Keeping your Angular projects up-to-date
Angular Versioning and Releases describes the level of change that you can expect based a release's version number. It also describes supported update...
Read more >
Usage of Angular libraries published to npm
Libraries are published as npm packages, usually together with schematics that integrate them with the Angular CLI. To integrate reusable library code into...
Read more >
Overview of Angular libraries
An Angular library is an Angular project that differs from an application in that it cannot run on its own. A library must...
Read more >
Angular versioning and releases
Angular version numbers have three parts: major.minor.patch . For example, version 7.2.11 indicates major version 7, minor version 2, and patch level 11....
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