Skip to content

Commit

Permalink
refactor: Remove some more uses of AnyDuringMigration. (#6970)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko authored Apr 10, 2023
1 parent 5a671da commit b32e76d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion core/blockly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ Names.prototype.populateProcedures =
function(this: Names, workspace: Workspace) {
const procedures = Procedures.allProcedures(workspace);
// Flatten the return vs no-return procedure lists.
const flattenedProcedures: AnyDuringMigration[][] =
const flattenedProcedures =
procedures[0].concat(procedures[1]);
for (let i = 0; i < flattenedProcedures.length; i++) {
this.getName(flattenedProcedures[i][0], Names.NameType.PROCEDURE);
Expand Down
36 changes: 15 additions & 21 deletions core/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ import {WorkspaceSvg} from './workspace_svg.js';
*/
export function inject(
container: Element|string, opt_options?: BlocklyOptions): WorkspaceSvg {
let containerElement: Element|null = null;
if (typeof container === 'string') {
// AnyDuringMigration because: Type 'Element | null' is not assignable to
// type 'string | Element'.
container = (document.getElementById(container) ||
document.querySelector(container)) as AnyDuringMigration;
containerElement =
document.getElementById(container) || document.querySelector(container);
} else {
containerElement = container;
}
// Verify that the container is in document.
// AnyDuringMigration because: Argument of type 'string | Element' is not
// assignable to parameter of type 'Node'.
if (!container ||
!dom.containsNode(document, container as AnyDuringMigration)) {
if (!containerElement || !dom.containsNode(document, containerElement)) {
throw Error('Error: container is not in current document.');
}
const options = new Options(opt_options || {} as BlocklyOptions);
Expand All @@ -58,9 +56,7 @@ export function inject(
subContainer.tabIndex = 0;
aria.setState(subContainer, aria.State.LABEL, Msg['WORKSPACE_ARIA_LABEL']);

// AnyDuringMigration because: Property 'appendChild' does not exist on type
// 'string | Element'.
(container as AnyDuringMigration).appendChild(subContainer);
containerElement.appendChild(subContainer);
const svg = createDom(subContainer, options);

// Create surfaces for dragging things. These are optimizations
Expand All @@ -76,16 +72,12 @@ export function inject(

// Keep focus on the first workspace so entering keyboard navigation looks
// correct.
// AnyDuringMigration because: Argument of type 'WorkspaceSvg' is not
// assignable to parameter of type 'Workspace'.
common.setMainWorkspace(workspace as AnyDuringMigration);
common.setMainWorkspace(workspace);

common.svgResize(workspace);

subContainer.addEventListener('focusin', function() {
// AnyDuringMigration because: Argument of type 'WorkspaceSvg' is not
// assignable to parameter of type 'Workspace'.
common.setMainWorkspace(workspace as AnyDuringMigration);
common.setMainWorkspace(workspace);
});

return workspace;
Expand Down Expand Up @@ -213,8 +205,7 @@ function init(mainWorkspace: WorkspaceSvg) {

// Suppress the browser's context menu.
browserEvents.conditionalBind(
svg.parentNode as Element, 'contextmenu', null,
function(e: AnyDuringMigration) {
svg.parentNode as Element, 'contextmenu', null, function(e: Event) {
if (!browserEvents.isTargetInput(e)) {
e.preventDefault();
}
Expand Down Expand Up @@ -369,13 +360,16 @@ function loadSounds(pathToMedia: string, workspace: WorkspaceSvg) {
'delete');

// Bind temporary hooks that preload the sounds.
const soundBinds: AnyDuringMigration[] = [];
const soundBinds: browserEvents.Data[] = [];
/**
*
*/
function unbindSounds() {
while (soundBinds.length) {
browserEvents.unbind(soundBinds.pop());
const oldSoundBinding = soundBinds.pop();
if (oldSoundBinding) {
browserEvents.unbind(oldSoundBinding);
}
}
audioMgr.preload();
}
Expand Down
3 changes: 1 addition & 2 deletions core/theme/classic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ const categoryStyles = {
* Classic theme.
* Contains multi-coloured border to create shadow effect.
*/
export const Classic = new Theme(
'classic', defaultBlockStyles as AnyDuringMigration, categoryStyles);
export const Classic = new Theme('classic', defaultBlockStyles, categoryStyles);

0 comments on commit b32e76d

Please sign in to comment.