From c2cbed1146bab6ff546764146125cf2d2d3fe2db Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Thu, 15 Sep 2022 12:48:40 -0700 Subject: [PATCH] fix: some AnyDuringMigration (#6430) * fix: remove some AnyDuringMigrations * fix: some instances of AnyDuringMigration * fix: some AnyDuringMigration * chore: revert comment removal --- core/block.ts | 6 ++---- core/block_svg.ts | 29 ++++++++--------------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/core/block.ts b/core/block.ts index 00878f332f1..a9956575415 100644 --- a/core/block.ts +++ b/core/block.ts @@ -580,13 +580,11 @@ export class Block implements IASTNodeLocation, IDeletable { */ getSurroundParent(): this|null { /* eslint-disable-next-line @typescript-eslint/no-this-alias */ - let block = this; + let block: this|null = this; let prevBlock; do { prevBlock = block; - // AnyDuringMigration because: Type 'Block | null' is not assignable to - // type 'this'. - block = block.getParent() as AnyDuringMigration; + block = block.getParent(); if (!block) { // Ran off the top. return null; diff --git a/core/block_svg.ts b/core/block_svg.ts index a0322fad78e..1da3bd32b32 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -333,9 +333,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, } dom.startTextWidthCache(); - // AnyDuringMigration because: Argument of type 'Block | null' is not - // assignable to parameter of type 'Block'. - super.setParent(newParent as AnyDuringMigration); + super.setParent(newParent); dom.stopTextWidthCache(); const svgRoot = this.getSvgRoot(); @@ -642,10 +640,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, } const input = this.getInput(collapsedInputName) || this.appendDummyInput(collapsedInputName); - // AnyDuringMigration because: Argument of type 'FieldLabel' is not - // assignable to parameter of type 'string | Field'. - input.appendField( - new FieldLabel(text) as AnyDuringMigration, collapsedFieldName); + input.appendField(new FieldLabel(text), collapsedFieldName); } /** @@ -737,9 +732,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, if (menuOptions && menuOptions.length) { ContextMenu.show(e, menuOptions, this.RTL); - // AnyDuringMigration because: Argument of type 'this' is not assignable - // to parameter of type 'Block | null'. - ContextMenu.setCurrentBlock(this as AnyDuringMigration); + ContextMenu.setCurrentBlock(this); } } @@ -958,16 +951,12 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, if (this.isInsertionMarker_) { return null; } - // AnyDuringMigration because: Argument of type 'this' is not assignable to - // parameter of type 'Block'. AnyDuringMigration because: Argument of type - // 'this' is not assignable to parameter of type 'Block'. return { - saveInfo: blocks.save( - this as AnyDuringMigration, - {addCoordinates: true, addNextBlocks: false}) as + saveInfo: + blocks.save(this, {addCoordinates: true, addNextBlocks: false}) as blocks.State, source: this.workspace, - typeCounts: common.getBlockTypeCounts(this as AnyDuringMigration, true), + typeCounts: common.getBlockTypeCounts(this, true), }; } @@ -1278,7 +1267,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, */ bringToFront() { /* eslint-disable-next-line @typescript-eslint/no-this-alias */ - let block = this; + let block: this|null = this; do { const root = block.getSvgRoot(); const parent = root.parentNode; @@ -1287,9 +1276,7 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, if (childNodes[childNodes.length - 1] !== root) { parent!.appendChild(root); } - // AnyDuringMigration because: Type 'BlockSvg | null' is not assignable - // to type 'this'. - block = block.getParent() as AnyDuringMigration; + block = block.getParent(); } while (block); }