Skip to content

Commit

Permalink
fix: some AnyDuringMigration (google#6430)
Browse files Browse the repository at this point in the history
* fix: remove some AnyDuringMigrations

* fix: some instances of AnyDuringMigration

* fix: some AnyDuringMigration

* chore: revert comment removal
  • Loading branch information
rachel-fenichel authored Sep 15, 2022
1 parent 5b07e1d commit c2cbed1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
6 changes: 2 additions & 4 deletions core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
29 changes: 8 additions & 21 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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),
};
}

Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit c2cbed1

Please sign in to comment.