diff --git a/components/notification/notification-container.component.ts b/components/notification/notification-container.component.ts index 77f9b6fd94..70a5bf843d 100644 --- a/components/notification/notification-container.component.ts +++ b/components/notification/notification-container.component.ts @@ -5,7 +5,6 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ViewEncapsulation } from '@angular/core'; import { NotificationConfig, NzConfigKey, NzConfigService } from 'ng-zorro-antd/core/config'; -import { warnDeprecation } from 'ng-zorro-antd/core/logger'; import { toCssPixel } from 'ng-zorro-antd/core/util'; import { NzMNContainerComponent } from 'ng-zorro-antd/message'; @@ -146,13 +145,7 @@ export class NzNotificationContainerComponent extends NzMNContainerComponent { } protected mergeOptions(options?: NzNotificationDataOptions): NzNotificationDataOptions { - const { nzPosition } = options ?? {}; - - if (nzPosition) { - warnDeprecation('`nzPosition` of NzNotificationDataOptions is deprecated and would be removed in 10.0.0. Use `nzPlacement` instead.'); - } - const { nzDuration, nzAnimate, nzPauseOnHover, nzPlacement } = this.config; - return { nzDuration, nzAnimate, nzPauseOnHover, nzPlacement: nzPlacement || nzPosition, ...options }; + return { nzDuration, nzAnimate, nzPauseOnHover, nzPlacement: nzPlacement, ...options }; } } diff --git a/components/notification/typings.ts b/components/notification/typings.ts index c986276630..700d385cd3 100644 --- a/components/notification/typings.ts +++ b/components/notification/typings.ts @@ -20,11 +20,6 @@ export interface NzNotificationDataOptions { nzDuration?: number; nzAnimate?: boolean; nzPauseOnHover?: boolean; - - /** - * @deprecated use nzPlacement instead, this would be removed in 10.0.0 - */ - nzPosition?: NzNotificationPlacement; } export interface NzNotificationData { @@ -43,9 +38,3 @@ export interface NzNotificationData { } export type NzNotificationRef = Pick, 'onClose' | 'onClick' | 'messageId'>; - -/** - * @deprecated use `NzNotificationRef` instead - * @breaking-change 10.0.0 - */ -export type NzNotificationDataFilled = NzNotificationRef; diff --git a/schematics/ng-update/data/class-names.ts b/schematics/ng-update/data/class-names.ts index 00e02d981f..c469fd934e 100644 --- a/schematics/ng-update/data/class-names.ts +++ b/schematics/ng-update/data/class-names.ts @@ -14,6 +14,12 @@ export const classNames: VersionChanges = { {replace: 'UploadXHRArgs', replaceWith: 'NzUploadXHRArgs'} ] }, + { + pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5779', + changes: [ + {replace: 'NzNotificationDataFilled', replaceWith: 'NzNotificationRef'} + ] + }, { pr: 'https://github.com/NG-ZORRO/ng-zorro-antd/pull/5778', changes: [ diff --git a/schematics/ng-update/data/property-names.ts b/schematics/ng-update/data/property-names.ts index 42554c3d74..91ca81e3ec 100644 --- a/schematics/ng-update/data/property-names.ts +++ b/schematics/ng-update/data/property-names.ts @@ -1,4 +1,16 @@ -import { PropertyNameUpgradeData, VersionChanges } from '@angular/cdk/schematics'; +import { PropertyNameUpgradeData, TargetVersion, VersionChanges } from '@angular/cdk/schematics'; -export const propertyNames: VersionChanges = {}; +export const propertyNames: VersionChanges = { + [TargetVersion.V10]: [{ + pr: '', + changes: [ + { + replace: 'nzPosition', + replaceWith: 'nzPlacement', + whitelist: {classes: ['NzNotificationDataOptions']} + } + ] + } + ] +}; diff --git a/schematics/ng-update/test-cases/v10/notification-deprecated.spec.ts b/schematics/ng-update/test-cases/v10/notification-deprecated.spec.ts new file mode 100644 index 0000000000..6b3ab1f466 --- /dev/null +++ b/schematics/ng-update/test-cases/v10/notification-deprecated.spec.ts @@ -0,0 +1,67 @@ +import { getSystemPath, normalize, virtualFs } from '@angular-devkit/core'; +import { TempScopedNodeJsSyncHost } from '@angular-devkit/core/node/testing'; +import { HostTree } from '@angular-devkit/schematics'; +import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; +import * as shx from 'shelljs'; +import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config'; + +describe('upload migration', () => { + let runner: SchematicTestRunner; + let host: TempScopedNodeJsSyncHost; + let tree: UnitTestTree; + let tmpDirPath: string; + let previousWorkingDir: string; + + beforeEach(() => { + runner = new SchematicTestRunner('test', require.resolve('../../../migration.json')); + host = new TempScopedNodeJsSyncHost(); + tree = new UnitTestTree(new HostTree(host)); + + writeFile('/tsconfig.json', JSON.stringify(SchematicsTestTsConfig)); + writeFile('/angular.json', JSON.stringify(SchematicsTestNGConfig)); + + previousWorkingDir = shx.pwd(); + tmpDirPath = getSystemPath(host.root); + + shx.cd(tmpDirPath); + + writeFakeAngular(); + }); + + afterEach(() => { + shx.cd(previousWorkingDir); + shx.rm('-r', tmpDirPath); + }); + + function writeFakeAngular(): void { writeFile('/node_modules/@angular/core/index.d.ts', ``); } + + function writeFile(filePath: string, contents: string): void { + host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents)); + } + + // tslint:disable-next-line:no-any + async function runMigration(): Promise { + await runner.runSchematicAsync('migration-v10', {}, tree).toPromise(); + } + + describe('Property names', () => { + + it('should replace deprecated property names', async() => { + writeFile('/index.ts', ` +export interface NzNotificationDataOptions { + nzPlacement?: any; + nzPosition?: any; +} +const option: NzNotificationDataOptions = {}; +console.log(option.nzPosition);`); + + await runMigration(); + const content = tree.readContent('/index.ts'); + + expect(content).toContain(`console.log(option.nzPlacement)`); + expect(content).not.toContain(`console.log(option.nzPosition)`); + }); + + }); + +});