Skip to content

Commit

Permalink
Add deprecation warning to Ember.assign
Browse files Browse the repository at this point in the history
  • Loading branch information
nlfurniss authored and mixonic committed Aug 1, 2021
1 parent 015bd42 commit 826daa7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@ember/deprecated-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export const JQUERY_INTEGRATION = !!'3.9.0';
export const APP_CTRL_ROUTER_PROPS = !!'3.10.0-beta.1';
export const MOUSE_ENTER_LEAVE_MOVE_EVENTS = !!'3.13.0-beta.1';
export const PARTIALS = !!'3.15.0-beta.1';
export const ASSIGN = !!'4.0.0';
16 changes: 16 additions & 0 deletions packages/@ember/polyfills/lib/assign.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { deprecate } from '@ember/debug';

/**
@module @ember/polyfills
*/
Expand Down Expand Up @@ -28,6 +30,20 @@ export function assign(target: object, ...sources: any[]): any;
@static
*/
export function assign(target: object) {
deprecate(
'Use of `assign` has been deprecated. Please use `Object.assign` or the spread operator instead.',
false,
{
id: 'ember-polyfills.deprecate-assign',
until: '5.0.0',
url: 'https://deprecations.emberjs.com/v4.x/#toc_ember-polyfills-deprecate-assign',
for: 'ember-source',
since: {
enabled: '4.0.0',
},
}
);

for (let i = 1; i < arguments.length; i++) {
let arg = arguments[i];
if (!arg) {
Expand Down
4 changes: 3 additions & 1 deletion packages/@ember/polyfills/tests/assign_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ moduleFor(
'Ember.assign (polyfill)',
class extends AssignTests {
assign() {
return assignPolyfill(...arguments);
return expectDeprecation(() => {
assignPolyfill(...arguments);
}, 'Use of `assign` has been deprecated. Please use `Object.assign` or the spread operator instead.');
}
}
);
Expand Down

0 comments on commit 826daa7

Please sign in to comment.