From 9a3cf661a2f464503acde5eac6f0b3de949b292c Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Mon, 2 Aug 2021 18:13:38 +0200 Subject: [PATCH] refactor(core): update peerDependencies to allow rxjs7 (#42991) We can't update the framework to rxjs7 until version 13, because it contains breaking changes, but we can allow users to opt into it since all of our code should be compatible. These changes expand the allowed version range of rxjs and add an integration test to verify that we don't get compilation errors. Note that we also have a test that runs the AIO examples against rxjs 7 already (#42660). Fixes #41897. PR Close #42991 --- integration/BUILD.bazel | 1 + integration/typings_test_rxjs7/include-all.ts | 69 +++++++++++++++++++ integration/typings_test_rxjs7/package.json | 28 ++++++++ integration/typings_test_rxjs7/tsconfig.json | 26 +++++++ packages/common/package.json | 2 +- packages/common/test/pipes/async_pipe_spec.ts | 2 +- packages/core/package.json | 2 +- .../test/acceptance/property_binding_spec.ts | 2 +- packages/elements/package.json | 2 +- packages/forms/package.json | 2 +- .../angular-in-memory-web-api/package.json | 6 +- packages/router/package.json | 2 +- 12 files changed, 134 insertions(+), 10 deletions(-) create mode 100644 integration/typings_test_rxjs7/include-all.ts create mode 100644 integration/typings_test_rxjs7/package.json create mode 100644 integration/typings_test_rxjs7/tsconfig.json diff --git a/integration/BUILD.bazel b/integration/BUILD.bazel index 6c9dfc1da1..23b8b96dd8 100644 --- a/integration/BUILD.bazel +++ b/integration/BUILD.bazel @@ -88,6 +88,7 @@ INTEGRATION_TESTS = { "service-worker-schema": {}, "side-effects": {"tags": ["no-ivy-aot"]}, "terser": {}, + "typings_test_rxjs7": {}, "typings_test_ts41": { # Special case for `typings_test_ts41` test as we want to pin # `typescript` at version 4.1.x for that test and not link to the diff --git a/integration/typings_test_rxjs7/include-all.ts b/integration/typings_test_rxjs7/include-all.ts new file mode 100644 index 0000000000..86b57f2789 --- /dev/null +++ b/integration/typings_test_rxjs7/include-all.ts @@ -0,0 +1,69 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + + + +import * as animations from '@angular/animations'; +import * as animationsBrowser from '@angular/animations/browser'; +import * as animationsBrowserTesting from '@angular/animations/browser/testing'; +import * as common from '@angular/common'; +import * as commonHttp from '@angular/common/http'; +import * as commonTesting from '@angular/common/testing'; +import * as commonHttpTesting from '@angular/common/testing'; +import * as compiler from '@angular/compiler'; +import * as compilerTesting from '@angular/compiler/testing'; +import * as core from '@angular/core'; +import * as coreTesting from '@angular/core/testing'; +import * as elements from '@angular/elements'; +import * as forms from '@angular/forms'; +import * as platformBrowser from '@angular/platform-browser'; +import * as platformBrowserDynamic from '@angular/platform-browser-dynamic'; +import * as platformBrowserDynamicTesting from '@angular/platform-browser-dynamic/testing'; +import * as platformBrowserAnimations from '@angular/platform-browser/animations'; +import * as platformBrowserTesting from '@angular/platform-browser/testing'; +import * as platformServer from '@angular/platform-server'; +import * as platformServerInit from '@angular/platform-server/init'; +import * as platformServerTesting from '@angular/platform-server/testing'; +import * as router from '@angular/router'; +import * as routerTesting from '@angular/router/testing'; +import * as routerUpgrade from '@angular/router/upgrade'; +import * as serviceWorker from '@angular/service-worker'; +import * as upgrade from '@angular/upgrade'; +import * as upgradeStatic from '@angular/upgrade/static'; +import * as upgradeTesting from '@angular/upgrade/static/testing'; + +export default { + animations, + animationsBrowser, + animationsBrowserTesting, + common, + commonTesting, + commonHttp, + commonHttpTesting, + compiler, + compilerTesting, + core, + coreTesting, + elements, + forms, + platformBrowser, + platformBrowserTesting, + platformBrowserDynamic, + platformBrowserDynamicTesting, + platformBrowserAnimations, + platformServer, + platformServerInit, + platformServerTesting, + router, + routerTesting, + routerUpgrade, + serviceWorker, + upgrade, + upgradeStatic, + upgradeTesting, +}; diff --git a/integration/typings_test_rxjs7/package.json b/integration/typings_test_rxjs7/package.json new file mode 100644 index 0000000000..4161f8d00a --- /dev/null +++ b/integration/typings_test_rxjs7/package.json @@ -0,0 +1,28 @@ +{ + "name": "angular-integration", + "description": "Assert that users with rxjs 7 can type-check an Angular application", + "version": "0.0.0", + "license": "MIT", + "dependencies": { + "@angular/animations": "file:../../dist/packages-dist/animations", + "@angular/common": "file:../../dist/packages-dist/common", + "@angular/compiler": "file:../../dist/packages-dist/compiler", + "@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli", + "@angular/core": "file:../../dist/packages-dist/core", + "@angular/elements": "file:../../dist/packages-dist/elements", + "@angular/forms": "file:../../dist/packages-dist/forms", + "@angular/platform-browser": "file:../../dist/packages-dist/platform-browser", + "@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic", + "@angular/platform-server": "file:../../dist/packages-dist/platform-server", + "@angular/router": "file:../../dist/packages-dist/router", + "@angular/service-worker": "file:../../dist/packages-dist/service-worker", + "@angular/upgrade": "file:../../dist/packages-dist/upgrade", + "@types/jasmine": "file:../../node_modules/@types/jasmine", + "rxjs": "^7.3.0", + "typescript": "file:../../node_modules/typescript", + "zone.js": "file:../../dist/zone.js-dist/archive/zone.js.tgz" + }, + "scripts": { + "test": "tsc" + } +} diff --git a/integration/typings_test_rxjs7/tsconfig.json b/integration/typings_test_rxjs7/tsconfig.json new file mode 100644 index 0000000000..30e25c2209 --- /dev/null +++ b/integration/typings_test_rxjs7/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "experimentalDecorators": true, + "module": "commonjs", + "moduleResolution": "node", + "outDir": "./dist/out-tsc", + "rootDir": ".", + "target": "es5", + "lib": [ + "es5", + "dom", + "es2015.collection", + "es2015.iterable", + "es2015.promise" + ], + "types": [], + }, + "files": [ + "include-all.ts", + "node_modules/@types/jasmine/index.d.ts" + ] +} diff --git a/packages/common/package.json b/packages/common/package.json index f724fee08f..f9ad0716b0 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -13,7 +13,7 @@ }, "peerDependencies": { "@angular/core": "0.0.0-PLACEHOLDER", - "rxjs": "^6.5.3" + "rxjs": "^6.5.3 || ^7.0.0" }, "repository": { "type": "git", diff --git a/packages/common/test/pipes/async_pipe_spec.ts b/packages/common/test/pipes/async_pipe_spec.ts index ef51153240..51abaab62f 100644 --- a/packages/common/test/pipes/async_pipe_spec.ts +++ b/packages/common/test/pipes/async_pipe_spec.ts @@ -22,7 +22,7 @@ import {Subscribable, Unsubscribable} from 'rxjs'; // the implementation does not rely on other methods: const wrapSubscribable = (input: Subscribable): Subscribable => ({ subscribe(...args: any): Unsubscribable { - const subscription = input.subscribe(...args); + const subscription = input.subscribe.apply(input, args); return { unsubscribe() { subscription.unsubscribe(); diff --git a/packages/core/package.json b/packages/core/package.json index e95a79abec..e0b585d592 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -11,7 +11,7 @@ "tslib": "^2.2.0" }, "peerDependencies": { - "rxjs": "^6.5.3", + "rxjs": "^6.5.3 || ^7.0.0", "zone.js": "~0.11.4" }, "repository": { diff --git a/packages/core/test/acceptance/property_binding_spec.ts b/packages/core/test/acceptance/property_binding_spec.ts index fdf7ca9a4b..3a5b9645a3 100644 --- a/packages/core/test/acceptance/property_binding_spec.ts +++ b/packages/core/test/acceptance/property_binding_spec.ts @@ -187,7 +187,7 @@ describe('property bindings', () => { }) class OtherDir { @Input() id: number|undefined; - @Output('click') clickStream = new EventEmitter(); + @Output('click') clickStream = new EventEmitter(); } @Directive({ diff --git a/packages/elements/package.json b/packages/elements/package.json index 95b74663b1..3da5fa0277 100644 --- a/packages/elements/package.json +++ b/packages/elements/package.json @@ -13,7 +13,7 @@ "peerDependencies": { "@angular/core": "0.0.0-PLACEHOLDER", "@angular/platform-browser": "0.0.0-PLACEHOLDER", - "rxjs": "^6.5.3" + "rxjs": "^6.5.3 || ^7.0.0" }, "repository": { "type": "git", diff --git a/packages/forms/package.json b/packages/forms/package.json index 1d9931e480..33cb036b42 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -14,7 +14,7 @@ "@angular/core": "0.0.0-PLACEHOLDER", "@angular/common": "0.0.0-PLACEHOLDER", "@angular/platform-browser": "0.0.0-PLACEHOLDER", - "rxjs": "^6.5.3" + "rxjs": "^6.5.3 || ^7.0.0" }, "repository": { "type": "git", diff --git a/packages/misc/angular-in-memory-web-api/package.json b/packages/misc/angular-in-memory-web-api/package.json index 796d9da10e..d0621050f6 100644 --- a/packages/misc/angular-in-memory-web-api/package.json +++ b/packages/misc/angular-in-memory-web-api/package.json @@ -5,9 +5,9 @@ "author": "angular", "license": "MIT", "peerDependencies": { - "@angular/core": "^12.0.0-next.6", - "@angular/common": "^12.0.0-next.6", - "rxjs": "^6.5.3" + "@angular/core": "^12.0.0", + "@angular/common": "^12.0.0", + "rxjs": "^6.5.3 || ^7.0.0" }, "dependencies": { "tslib": "^2.2.0" diff --git a/packages/router/package.json b/packages/router/package.json index 89860e526b..30e91c1a5a 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -27,7 +27,7 @@ "@angular/core": "0.0.0-PLACEHOLDER", "@angular/common": "0.0.0-PLACEHOLDER", "@angular/platform-browser": "0.0.0-PLACEHOLDER", - "rxjs": "^6.5.3" + "rxjs": "^6.5.3 || ^7.0.0" }, "ng-update": { "packageGroup": "NG_UPDATE_PACKAGE_GROUP"