Skip to content

Commit 8fc97ac

Browse files
crisbetojelbourn
authored andcommitted
fix: add peer dependency on @angular/forms (#15133)
Adds `@angular/forms` to the list of peer dependencies, because there are around 10 Material components that are importing symbols from it. Fixes #15085.
1 parent 5216d38 commit 8fc97ac

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/lib/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"@angular/animations": "0.0.0-NG",
2626
"@angular/cdk": "0.0.0-PLACEHOLDER",
2727
"@angular/core": "0.0.0-NG",
28-
"@angular/common": "0.0.0-NG"
28+
"@angular/common": "0.0.0-NG",
29+
"@angular/forms": "0.0.0-NG"
2930
},
3031
"dependencies": {
3132
"tslib": "^1.7.1"

src/lib/schematics/ng-add/index.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ describe('ng-add schematic', () => {
4848
expect(dependencies['@angular/material']).toBeDefined();
4949
expect(dependencies['@angular/cdk']).toBeDefined();
5050
expect(dependencies['hammerjs']).toBeDefined();
51+
expect(dependencies['@angular/forms']).toBe(angularCoreVersion,
52+
'Expected the @angular/forms package to have the same version as @angular/core.');
5153
expect(dependencies['@angular/animations']).toBe(angularCoreVersion,
5254
'Expected the @angular/animations package to have the same version as @angular/core.');
5355

src/lib/schematics/ng-add/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ export default function(options: Schema): Rule {
2525
// of the CLI project. This tag should be preferred because all Angular dependencies should
2626
// have the same version tag if possible.
2727
const ngCoreVersionTag = getPackageVersionFromPackageJson(host, '@angular/core');
28+
const angularDependencyVersion = ngCoreVersionTag || requiredAngularVersionRange;
2829

2930
// In order to align the Material and CDK version with the other Angular dependencies,
3031
// we use tilde instead of caret. This is default for Angular dependencies in new CLI projects.
3132
addPackageToPackageJson(host, '@angular/cdk', `~${materialVersion}`);
3233
addPackageToPackageJson(host, '@angular/material', `~${materialVersion}`);
33-
addPackageToPackageJson(host, '@angular/animations',
34-
ngCoreVersionTag || requiredAngularVersionRange);
34+
addPackageToPackageJson(host, '@angular/forms', angularDependencyVersion);
35+
addPackageToPackageJson(host, '@angular/animations', angularDependencyVersion);
3536

3637
if (options.gestures) {
3738
addPackageToPackageJson(host, 'hammerjs', hammerjsVersion);

0 commit comments

Comments
 (0)