refactor: Remove more uses of AnyDuringMigration. (#6383)

* refactor: Remove uses of AnyDuringMigration from flyout_base.ts.

* refactor: Remove uses of AnyDuringMigration from flyout_metrics_manager.ts.

* refactor: Remove uses of AnyDuringMigration from variables_dynamic.ts.

* refactor: Remove uses of AnyDuringMigration from procedures.ts.

* refactor: Remove uses of AnyDuringMigration from generator.ts.

* refactor: Remove some uses of AnyDuringMigration from menu.ts.

* refactor: Remove uses of AnyDuringMigration from mutator.ts.

* refactor: Remove uses of AnyDuringMigration from variables.ts.

* refactor: Remove uses of AnyDuringMigration from array.ts.

* refactor: Remove uses of AnyDuringMigration from aria.ts.

* refactor: Remove uses of AnyDuringMigration in basic_cursor.ts.

* refactor: Remove uses of AnyDuringMigration in dropdowndiv.ts.

* refactor: Remove uses of AnyDuringMigration in utils.ts.

* refactor: Remove uses of AnyDuringMigration from menuitem.ts.

* refactor: Remove uses of AnyDuringMigration from idgenerator.ts.

* refactor: Remove uses of AnyDuringMigration in block_animations.ts.

* refactor: Initialize definitions and functionNames in generator.ts by default.
This commit is contained in:
Aaron Dodson
2022-08-24 16:06:38 -07:00
committed by GitHub
parent e50ad59ffe
commit 3a36ed5116
19 changed files with 187 additions and 325 deletions

View File

@@ -152,7 +152,5 @@ export function setState(
value = value.join(' ');
}
const attrStateName = ARIA_PREFIX + stateName;
// AnyDuringMigration because: Argument of type 'string | number | boolean'
// is not assignable to parameter of type 'string'.
element.setAttribute(attrStateName, value as AnyDuringMigration);
element.setAttribute(attrStateName, `${value}`);
}

View File

@@ -18,8 +18,7 @@ goog.declareModuleId('Blockly.utils.array');
* @alias Blockly.array.removeElem
* @internal
*/
export function removeElem(
arr: AnyDuringMigration[], value: AnyDuringMigration): boolean {
export function removeElem<T>(arr: Array<T>, value: T): boolean {
const i = arr.indexOf(value);
if (i === -1) {
return false;

View File

@@ -12,6 +12,15 @@
import * as goog from '../../closure/goog/goog.js';
goog.declareModuleId('Blockly.utils.idGenerator');
/**
* Legal characters for the universally unique IDs. Should be all on
* a US keyboard. No characters that conflict with XML or JSON.
* Requests to remove additional 'problematic' characters from this
* soup will be denied. That's your failure to properly escape in
* your own environment. Issues #251, #625, #682, #1304.
*/
const soup = '!#$%()*+,-./:;=?@[]^_`{|}~' +
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
/**
* Namespace object for internal implementations we want to be able to
@@ -19,7 +28,23 @@ goog.declareModuleId('Blockly.utils.idGenerator');
*
* @ignore
*/
const internal = {};
const internal = {
/**
* Generate a random unique ID. This should be globally unique.
* 87 characters ^ 20 length > 128 bits (better than a UUID).
*
* @returns A globally unique ID string.
*/
genUid: () => {
const length = 20;
const soupLength = soup.length;
const id = [];
for (let i = 0; i < length; i++) {
id[i] = soup.charAt(Math.random() * soupLength);
}
return id.join('');
},
};
export const TEST_ONLY = internal;
/** Next unique ID to use. */
@@ -40,33 +65,6 @@ export function getNextUniqueId(): string {
return 'blockly-' + (nextId++).toString(36);
}
/**
* Legal characters for the universally unique IDs. Should be all on
* a US keyboard. No characters that conflict with XML or JSON.
* Requests to remove additional 'problematic' characters from this
* soup will be denied. That's your failure to properly escape in
* your own environment. Issues #251, #625, #682, #1304.
*/
const soup = '!#$%()*+,-./:;=?@[]^_`{|}~' +
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
/**
* Generate a random unique ID. This should be globally unique.
* 87 characters ^ 20 length > 128 bits (better than a UUID).
*
* @returns A globally unique ID string.
*/
// AnyDuringMigration because: Property 'genUid' does not exist on type '{}'.
(internal as AnyDuringMigration).genUid = function(): string {
const length = 20;
const soupLength = soup.length;
const id = [];
for (let i = 0; i < length; i++) {
id[i] = soup.charAt(Math.random() * soupLength);
}
return id.join('');
};
/**
* Generate a random unique ID.
*
@@ -75,6 +73,5 @@ const soup = '!#$%()*+,-./:;=?@[]^_`{|}~' +
* @alias Blockly.utils.idGenerator.genUid
*/
export function genUid(): string {
// AnyDuringMigration because: Property 'genUid' does not exist on type '{}'.
return (internal as AnyDuringMigration).genUid();
return internal.genUid();
}

View File

@@ -183,8 +183,7 @@ export function tokenizeInterpolation(message: string): (string|number)[] {
* @returns String with message references replaced.
* @alias Blockly.utils.parsing.replaceMessageReferences
*/
export function replaceMessageReferences(message: string|
AnyDuringMigration): string {
export function replaceMessageReferences(message: string|any): string {
if (typeof message !== 'string') {
return message;
}