Skip to content

Commit 84f0bbb

Browse files
author
mmart1n
committed
fix(*): remove deprecateDecorators and apply @deprecate tags
1 parent 14921f6 commit 84f0bbb

File tree

14 files changed

+87
-196
lines changed

14 files changed

+87
-196
lines changed

.github/CONTRIBUTING.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,27 @@ Write migrations.
170170

171171
## Deprecating methods
172172
When a method is deprecated a few steps have to be done:
173-
1. Add deprecation warning message by decorating the method with `@DeprecateMethod` decorator from `deprecateDecorators.ts` file.
173+
1. Add the `@deprecated` tag at the begging of the method description followed by the version in which the method has been deprecated and what can be used instead. Example:
174+
```ts
175+
/**
176+
* @deprecated in version 12.1.0. Use 'data' instead
177+
*
178+
* The data record that populates the row
179+
*/
180+
public getRowData(): any {
181+
return this.data;
182+
}
183+
```
174184
2. Ensure that the deprecated method is no longer used in IgniteUI for Angular codebase, samples and documentation snippets.
175185
3. Write migrations.
176186

177187
## Deprecating class properties
178188
When a class property is deprecated a few steps have to be done:
179-
1. Add deprecation warning message by decorating the property with `@DeprecateProperty` decorator from `deprecateDecorators.ts` file.
189+
1. Add the `@deprecated` tag at the begging of the property description followed by the version in which the property has been deprecated and what can be used instead.
180190
2. Ensure that the deprecated property is no longer used in IgniteUI for Angular codebase, samples and documentation snippets.
181191
3. Write migrations.
182192

183-
NOTE: TypeScript disallows decorating both the get and set accessor for a single member. Instead, all decorators for the member must be applied to the first accessor specified in document order. This is because decorators apply to a Property Descriptor, which combines both the get and set accessor, not each declaration separately.
193+
NOTE: TypeScript disallows adding descriptions to both the get and set accessor for a single member. Instead, the description for the member must be applied to the first accessor specified in document order. Having this in mind the `@deprecated` tag is applied only once.
184194

185195
# Testing a PR
186196
In order to test a pull request that is awaiting test, perform the following actions.

projects/igniteui-angular/migrations/common/filterSourceDirs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { filter, Rule, SchematicContext, Tree } from '@angular-devkit/schematics
22
import { getWorkspace, getWorkspacePath, getProjectPaths } from './util';
33

44
/**
5-
* Filter tree to project source dirs
6-
*
75
* @deprecated Temporary
6+
*
7+
* Filter tree to project source dirs
88
*/
99
export const filterSourceDirs = (host: Tree, context: SchematicContext): Rule => {
1010
const configPath = getWorkspacePath(host);

projects/igniteui-angular/src/lib/banner/banner.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import { ToggleAnimationSettings } from '../expansion-panel/toggle-animation-com
1313

1414
export interface BannerEventArgs extends IBaseEventArgs {
1515
/**
16-
* @deprecated
17-
* To get a reference to the banner, use `owner` instead.
16+
* @deprecated in 12.1.0. To get a reference to the banner, use `owner` instead
1817
*/
1918
banner: IgxBannerComponent;
2019
event?: Event;

projects/igniteui-angular/src/lib/core/deprecateDecorators.ts

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,5 @@
11
import { isDevMode } from '@angular/core';
22

3-
/**
4-
* @hidden
5-
*/
6-
export const DeprecateClass = (message: string) => {
7-
let isMessageShown = false;
8-
9-
return <T extends new(...args: any[]) => any>(originalClass: T) => class extends originalClass {
10-
constructor(...args) {
11-
const target: any = originalClass;
12-
const targetName = typeof target === 'function' ? target.name : target.constructor.name;
13-
isMessageShown = showMessage(`${targetName}: ${message}`, isMessageShown);
14-
15-
super(...args);
16-
}
17-
};
18-
};
19-
20-
/**
21-
* @hidden
22-
*/
23-
export function DeprecateMethod(message: string): MethodDecorator {
24-
let isMessageShown = false;
25-
26-
return function(target: any, key: string, descriptor: PropertyDescriptor) {
27-
if (descriptor && descriptor.value) {
28-
const originalMethod = descriptor.value;
29-
30-
descriptor.value = function() {
31-
const targetName = typeof target === 'function' ? target.name : target.constructor.name;
32-
isMessageShown = showMessage(`${targetName}.${key}: ${message}`, isMessageShown);
33-
const args = [];
34-
for (const x of arguments) {
35-
args.push(x);
36-
}
37-
return originalMethod.call(this, ...args);
38-
};
39-
40-
return descriptor;
41-
}
42-
};
43-
}
44-
45-
/**
46-
* @hidden
47-
*/
48-
export function DeprecateProperty(message: string): PropertyDecorator {
49-
return function(target: any, key: string) {
50-
let isMessageShown = false;
51-
const messageToDisplay = `${target.constructor.name}.${key}: ${message}`;
52-
53-
// if the target already has the property defined
54-
const originalDescriptor = Object.getOwnPropertyDescriptor(target, key);
55-
if (originalDescriptor) {
56-
const getter = originalDescriptor.get;
57-
const setter = originalDescriptor.set;
58-
59-
if (getter) {
60-
originalDescriptor.get = function() {
61-
isMessageShown = showMessage(messageToDisplay, isMessageShown);
62-
return getter.call(this);
63-
};
64-
}
65-
66-
if (setter) {
67-
originalDescriptor.set = function(value) {
68-
isMessageShown = showMessage(messageToDisplay, isMessageShown);
69-
setter.call(this, value);
70-
};
71-
}
72-
73-
return originalDescriptor;
74-
}
75-
76-
// the target doesn't contain a descriptor for that property, so create one
77-
// use backing field to set/get the value of the property to ensure there won't be infinite recursive calls
78-
const newKey = generateUniqueKey(target, key);
79-
Object.defineProperty(target, key, {
80-
configurable: true,
81-
enumerable: true,
82-
set(value) {
83-
isMessageShown = showMessage(messageToDisplay, isMessageShown);
84-
this[newKey] = value;
85-
},
86-
get() {
87-
isMessageShown = showMessage(messageToDisplay, isMessageShown);
88-
return this[newKey];
89-
}
90-
});
91-
};
92-
}
93-
94-
/**
95-
* @hidden
96-
*/
97-
const generateUniqueKey = (target: any, key: string): string => {
98-
let newKey = '_' + key;
99-
while (target.hasOwnProperty(newKey)) {
100-
newKey = '_' + newKey;
101-
}
102-
103-
return newKey;
104-
};
105-
1063
/**
1074
* @hidden
1085
*/

projects/igniteui-angular/src/lib/directives/radio/radio-group.directive.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { IgxRippleModule } from '../ripple/ripple.directive';
1616
import { takeUntil } from 'rxjs/operators';
1717
import { noop, Subject } from 'rxjs';
1818
import { mkenum } from '../../core/utils';
19-
import { DeprecateProperty } from '../../core/deprecateDecorators';
2019

2120
/**
2221
* Determines the Radio Group alignment
@@ -129,16 +128,15 @@ export class IgxRadioGroupDirective implements AfterContentInit, ControlValueAcc
129128
}
130129

131130
/**
132-
* An @Input property that allows you to disable the radio group. By default it's false.
133-
*
134131
* @deprecated in version 12.2.0
135132
*
133+
* An input property that allows you to disable the radio group. By default it's false.
134+
*
136135
* @example
137136
* ```html
138137
* <igx-radio-group disabled></igx-radio-group>
139138
* ```
140139
*/
141-
@DeprecateProperty('`disabled` is deprecated.')
142140
@Input()
143141
public get disabled(): boolean {
144142
return this._disabled;
@@ -149,10 +147,10 @@ export class IgxRadioGroupDirective implements AfterContentInit, ControlValueAcc
149147
}
150148

151149
/**
152-
* Sets/gets the position of the `label` in the child radio buttons.
153-
*
154150
* @deprecated in version 12.2.0
155151
*
152+
* Sets/gets the position of the `label` in the child radio buttons.
153+
*
156154
* @remarks
157155
* If not set, `labelPosition` will have value `"after"`.
158156
*
@@ -161,7 +159,6 @@ export class IgxRadioGroupDirective implements AfterContentInit, ControlValueAcc
161159
* <igx-radio-group labelPosition = "before"></igx-radio-group>
162160
* ```
163161
*/
164-
@DeprecateProperty('`labelPosition` is deprecated.')
165162
@Input()
166163
public get labelPosition(): RadioLabelPosition | string {
167164
return this._labelPosition;

projects/igniteui-angular/src/lib/grids/cell.component.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { GridBaseAPIService } from './api.service';
1919
import { PlatformUtil } from '../core/utils';
2020
import { IgxGridBaseDirective } from './grid-base.directive';
2121
import { IgxGridSelectionService, ISelectionNode } from './selection/selection.service';
22-
import { DeprecateMethod } from '../core/deprecateDecorators';
2322
import { HammerGesturesManager } from '../core/touch';
2423
import { ColumnType } from './common/column.interface';
2524
import { RowType } from './common/row.interface';
@@ -662,19 +661,6 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
662661
private touchManager: HammerGesturesManager,
663662
protected platformUtil: PlatformUtil) { }
664663

665-
/**
666-
* @deprecated
667-
* Gets whether the cell is selected.
668-
* ```typescript
669-
* let isCellSelected = thid.cell.isCellSelected();
670-
* ```
671-
* @memberof IgxGridCellComponent
672-
*/
673-
@DeprecateMethod(`'isCellSelected' is deprecated. Use 'selected' property instead.`)
674-
public isCellSelected() {
675-
return this.selectionService.selected(this.selectionNode);
676-
}
677-
678664
/**
679665
* @hidden
680666
* @internal
@@ -719,6 +705,20 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
719705
});
720706
}
721707

708+
/**
709+
* @deprecated in version 8.2.0. Use 'selected' property instead
710+
*
711+
* Gets whether the cell is selected.
712+
*
713+
* ```typescript
714+
* let isCellSelected = thid.cell.isCellSelected();
715+
* ```
716+
* @memberof IgxGridCellComponent
717+
*/
718+
public isCellSelected() {
719+
return this.selectionService.selected(this.selectionNode);
720+
}
721+
722722
/**
723723
* @hidden
724724
* @internal

0 commit comments

Comments
 (0)