Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecate functions in object.ts #6387

Merged
merged 3 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}