Skip to content

Commit

Permalink
fix: deprecate functions in object.ts (google#6387)
Browse files Browse the repository at this point in the history
* fix: deprecate functions in object.ts

* chore: update deprecation dates and formats

* chore: redo deprecation dates again
  • Loading branch information
rachel-fenichel authored Aug 30, 2022
1 parent a785ab8 commit 9775b51
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
3 changes: 1 addition & 2 deletions core/shortcut_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,8 @@ export class ShortcutRegistry {
* @throws {Error} if the modifier is not in the valid modifiers list.
*/
private checkModifiers_(modifiers: KeyCodes[]) {
const validModifiers = object.values(ShortcutRegistry.modifierKeys);
for (let i = 0, modifier; modifier = modifiers[i]; i++) {
if (validModifiers.indexOf(modifier) < 0) {
if (!(modifier in ShortcutRegistry.modifierKeys)) {
throw new Error(modifier + ' is not a valid modifier key.');
}
}
Expand Down
12 changes: 6 additions & 6 deletions core/utils/deprecation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ goog.declareModuleId('Blockly.utils.deprecation');
* Warn developers that a function or property is deprecated.
*
* @param name The name of the function or property.
* @param deprecationDate The date of deprecation.
* Prefer 'month yyyy' or 'quarter yyyy' format.
* @param deletionDate The date of deletion, in the same format as the
* deprecation date.
* @param deprecationDate The date of deprecation. Prefer 'version n.0.0'
* format, and fall back to 'month yyyy' or 'quarter yyyy' format.
* @param deletionDate The date of deletion. Prefer 'version n.0.0'
* format, and fall back to 'month yyyy' or 'quarter yyyy' format.
* @param opt_use The name of a function or property to use instead, if any.
* @alias Blockly.utils.deprecation.warn
* @internal
*/
export function warn(
name: string, deprecationDate: string, deletionDate: string,
opt_use?: string) {
let msg = name + ' was deprecated on ' + deprecationDate +
' and will be deleted on ' + deletionDate + '.';
let msg = name + ' was deprecated in ' + deprecationDate +
' and will be deleted in ' + deletionDate + '.';
if (opt_use) {
msg += '\nUse ' + opt_use + ' instead.';
}
Expand Down
13 changes: 6 additions & 7 deletions core/utils/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import * as deprecation from './deprecation.js';
* @alias Blockly.utils.object.inherits
*/
export function inherits(childCtor: Function, parentCtor: Function) {
deprecation.warn(
'Blockly.utils.object.inherits', 'version 9.0.0', 'version 10.0.0');
// Set a .superClass_ property so that methods can call parent methods
// without hard-coding the parent class name.
// Could be replaced by ES6's super().
Expand Down Expand Up @@ -86,11 +88,8 @@ export function deepMerge(
* @alias Blockly.utils.object.values
*/
export function values(obj: AnyDuringMigration): AnyDuringMigration[] {
if (Object.values) {
return Object.values(obj);
}
// Fallback for IE.
return Object.keys(obj).map(function(e) {
return obj[e];
});
deprecation.warn(
'Blockly.utils.object.values', 'version 9.0.0', 'version 10.0.0',
'Object.values');
return Object.values(obj);
}

0 comments on commit 9775b51

Please sign in to comment.