diff --git a/.eslintrc.json b/.eslintrc.json index 6379c1fc6..4f28defcc 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -122,6 +122,8 @@ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }], + "func-call-spacing": ["off"], + "@typescript-eslint/func-call-spacing": ["warn"], // Temporarily disable. 23 problems. "@typescript-eslint/no-explicit-any": ["off"], // Temporarily disable. 128 problems. @@ -132,8 +134,6 @@ "@typescript-eslint/no-empty-function": ["off"], // Temporarily disable. 3 problems. "@typescript-eslint/no-empty-interface": ["off"], - // Temporarily disable. 34 problems. - "func-call-spacing": ["off"], // TsDoc rules (using JsDoc plugin) // Disable built-in jsdoc verifier. diff --git a/core/block.ts b/core/block.ts index a84827dcd..d3931094a 100644 --- a/core/block.ts +++ b/core/block.ts @@ -291,7 +291,7 @@ export class Block implements IASTNodeLocation, IDeletable { // Fire a create event. if (eventUtils.isEnabled()) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))!(this)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(this)); } } finally { if (!existingGroup) { @@ -323,7 +323,7 @@ export class Block implements IASTNodeLocation, IDeletable { this.unplug(healStack); if (eventUtils.isEnabled()) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_DELETE))!(this)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_DELETE))(this)); } if (this.onchangeWrapper_) { @@ -1248,8 +1248,8 @@ export class Block implements IASTNodeLocation, IDeletable { */ setInputsInline(newBoolean: boolean) { if (this.inputsInline !== newBoolean) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (this, 'inline', null, this.inputsInline, newBoolean)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + this, 'inline', null, this.inputsInline, newBoolean)); this.inputsInline = newBoolean; } } @@ -1318,8 +1318,8 @@ export class Block implements IASTNodeLocation, IDeletable { if (this.isEnabled() !== enabled) { const oldValue = this.disabled; this.disabled = !enabled; - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (this, 'disabled', null, oldValue, !enabled)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + this, 'disabled', null, oldValue, !enabled)); } } @@ -1357,8 +1357,8 @@ export class Block implements IASTNodeLocation, IDeletable { */ setCollapsed(collapsed: boolean) { if (this.collapsed_ !== collapsed) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (this, 'collapsed', null, this.collapsed_, collapsed)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + this, 'collapsed', null, this.collapsed_, collapsed)); this.collapsed_ = collapsed; } } @@ -2064,8 +2064,8 @@ export class Block implements IASTNodeLocation, IDeletable { if (this.commentModel.text === text) { return; } - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (this, 'comment', null, this.commentModel.text, text)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + this, 'comment', null, this.commentModel.text, text)); this.commentModel.text = text; // AnyDuringMigration because: Type 'string | null' is not assignable to // type 'string | Comment'. @@ -2111,7 +2111,7 @@ export class Block implements IASTNodeLocation, IDeletable { throw Error('Block has parent.'); } const event = - new (eventUtils.get(eventUtils.BLOCK_MOVE))!(this) as BlockMove; + new (eventUtils.get(eventUtils.BLOCK_MOVE))(this) as BlockMove; this.xy_.translate(dx, dy); event.recordNew(); eventUtils.fire(event); diff --git a/core/block_dragger.ts b/core/block_dragger.ts index 5e336fb96..33b0dcf83 100644 --- a/core/block_dragger.ts +++ b/core/block_dragger.ts @@ -163,8 +163,8 @@ export class BlockDragger implements IBlockDragger { /** Fire a UI event at the start of a block drag. */ protected fireDragStartEvent_() { - const event = new (eventUtils.get(eventUtils.BLOCK_DRAG))! - (this.draggingBlock_, true, this.draggingBlock_.getDescendants(false)); + const event = new (eventUtils.get(eventUtils.BLOCK_DRAG))( + this.draggingBlock_, true, this.draggingBlock_.getDescendants(false)); eventUtils.fire(event); } @@ -312,8 +312,8 @@ export class BlockDragger implements IBlockDragger { /** Fire a UI event at the end of a block drag. */ protected fireDragEndEvent_() { - const event = new (eventUtils.get(eventUtils.BLOCK_DRAG))! - (this.draggingBlock_, false, this.draggingBlock_.getDescendants(false)); + const event = new (eventUtils.get(eventUtils.BLOCK_DRAG))( + this.draggingBlock_, false, this.draggingBlock_.getDescendants(false)); eventUtils.fire(event); } @@ -352,8 +352,8 @@ export class BlockDragger implements IBlockDragger { /** Fire a move event at the end of a block drag. */ protected fireMoveEvent_() { - const event = new (eventUtils.get(eventUtils.BLOCK_MOVE))! - (this.draggingBlock_) as BlockMove; + const event = new (eventUtils.get(eventUtils.BLOCK_MOVE))( + this.draggingBlock_) as BlockMove; event.oldCoordinate = this.startXY_; event.recordNew(); eventUtils.fire(event); diff --git a/core/block_svg.ts b/core/block_svg.ts index 979de6774..0da93ef5b 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -279,8 +279,8 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, eventUtils.enable(); } } - const event = new (eventUtils.get(eventUtils.SELECTED))! - (oldId, this.id, this.workspace.id); + const event = new (eventUtils.get(eventUtils.SELECTED))( + oldId, this.id, this.workspace.id); eventUtils.fire(event); common.setSelected(this); this.addSelect(); @@ -294,8 +294,8 @@ export class BlockSvg extends Block implements IASTNodeLocationSvg, if (common.getSelected() !== this) { return; } - const event = new (eventUtils.get(eventUtils.SELECTED))! - (this.id, null, this.workspace.id); + const event = new (eventUtils.get(eventUtils.SELECTED))( + this.id, null, this.workspace.id); event.workspaceId = this.workspace.id; eventUtils.fire(event); common.setSelected(null); diff --git a/core/bubble_dragger.ts b/core/bubble_dragger.ts index 268d63c9f..769fcf4a1 100644 --- a/core/bubble_dragger.ts +++ b/core/bubble_dragger.ts @@ -192,8 +192,8 @@ export class BubbleDragger { /** Fire a move event at the end of a bubble drag. */ private fireMoveEvent_() { if (this.bubble instanceof WorkspaceCommentSvg) { - const event = new (eventUtils.get(eventUtils.COMMENT_MOVE))! - (this.bubble) as CommentMove; + const event = new (eventUtils.get(eventUtils.COMMENT_MOVE))( + this.bubble) as CommentMove; event.setOldCoordinate(this.startXY_); event.recordNew(); eventUtils.fire(event); diff --git a/core/comment.ts b/core/comment.ts index 07ce093d8..7831a2a0d 100644 --- a/core/comment.ts +++ b/core/comment.ts @@ -166,9 +166,9 @@ export class Comment extends Icon { */ function(this: Comment, _e: Event) { if (this.cachedText_ !== this.model_.text) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (this.block_, 'comment', null, this.cachedText_, - this.model_.text)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + this.block_, 'comment', null, this.cachedText_, + this.model_.text)); } }); this.onInputWrapper_ = browserEvents.conditionalBind( @@ -232,8 +232,8 @@ export class Comment extends Icon { if (visible === this.isVisible()) { return; } - eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))! - (this.block_, visible, 'comment')); + eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))( + this.block_, visible, 'comment')); this.model_.pinned = visible; if (visible) { this.createBubble_(); diff --git a/core/connection.ts b/core/connection.ts index 5f8ff8b79..73f86737f 100644 --- a/core/connection.ts +++ b/core/connection.ts @@ -116,7 +116,7 @@ export class Connection implements IASTNodeLocationWithBlock { let event; if (eventUtils.isEnabled()) { event = - new (eventUtils.get(eventUtils.BLOCK_MOVE))!(childBlock) as BlockMove; + new (eventUtils.get(eventUtils.BLOCK_MOVE))(childBlock) as BlockMove; } connectReciprocally(this, childConnection); childBlock.setParent(parentBlock); @@ -293,7 +293,7 @@ export class Connection implements IASTNodeLocationWithBlock { let event; if (eventUtils.isEnabled()) { event = - new (eventUtils.get(eventUtils.BLOCK_MOVE))!(childBlock) as BlockMove; + new (eventUtils.get(eventUtils.BLOCK_MOVE))(childBlock) as BlockMove; } const otherConnection = this.targetConnection; if (otherConnection) { diff --git a/core/contextmenu.ts b/core/contextmenu.ts index d29067d7a..350a1e62c 100644 --- a/core/contextmenu.ts +++ b/core/contextmenu.ts @@ -249,7 +249,7 @@ export function callbackFactory(block: Block, xml: Element): Function { eventUtils.enable(); } if (eventUtils.isEnabled() && !newBlock.isShadow()) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))!(newBlock)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(newBlock)); } newBlock.select(); }; diff --git a/core/dropdowndiv.ts b/core/dropdowndiv.ts index c1db53246..6158b73ca 100644 --- a/core/dropdowndiv.ts +++ b/core/dropdowndiv.ts @@ -328,6 +328,7 @@ export function show( const internal = { /** * Get sizing info about the bounding element. + * * @return An object containing size information about the bounding element * (bounding box and width/height). */ @@ -348,6 +349,7 @@ const internal = { /** * Helper to position the drop-down and the arrow, maintaining bounds. * See explanation of origin points in show. + * * @param primaryX Desired origin point x, in absolute px. * @param primaryY Desired origin point y, in absolute px. * @param secondaryX Secondary/alternative origin point x, in absolute px. diff --git a/core/events/utils.ts b/core/events/utils.ts index 6c9d280cf..782728eee 100644 --- a/core/events/utils.ts +++ b/core/events/utils.ts @@ -507,12 +507,16 @@ export function fromJson( * Gets the class for a specific event type from the registry. * * @param eventType The type of the event to get. - * @returns The event class with the given type or null if none exists. + * @returns The event class with the given type. * @alias Blockly.Events.utils.get */ export function get(eventType: string): - (new (...p1: AnyDuringMigration[]) => Abstract)|null { - return registry.getClass(registry.Type.EVENT, eventType); + (new (...p1: AnyDuringMigration[]) => Abstract) { + const event = registry.getClass(registry.Type.EVENT, eventType); + if (!event) { + throw new Error(`Event type ${eventType} not found in registry.`); + } + return event; } /** diff --git a/core/field.ts b/core/field.ts index f8e58f1ab..059ec0326 100644 --- a/core/field.ts +++ b/core/field.ts @@ -967,8 +967,8 @@ export abstract class Field implements IASTNodeLocationSvg, this.doValueUpdate_(newValue); if (source && eventUtils.isEnabled()) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (source, 'field', this.name || null, oldValue, newValue)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + source, 'field', this.name || null, oldValue, newValue)); } if (this.isDirty_) { this.forceRerender(); diff --git a/core/field_textinput.ts b/core/field_textinput.ts index 2872526cb..386e8bdd2 100644 --- a/core/field_textinput.ts +++ b/core/field_textinput.ts @@ -187,9 +187,9 @@ export class FieldTextInput extends Field { // Revert value when the text becomes invalid. this.value_ = this.htmlInput_!.getAttribute('data-untyped-default-value'); if (this.sourceBlock_ && eventUtils.isEnabled()) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (this.sourceBlock_, 'field', this.name || null, - oldValue, this.value_)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + this.sourceBlock_, 'field', this.name || null, oldValue, + this.value_)); } } } diff --git a/core/flyout_base.ts b/core/flyout_base.ts index 39f55b027..c315d9a71 100644 --- a/core/flyout_base.ts +++ b/core/flyout_base.ts @@ -991,13 +991,13 @@ export abstract class Flyout extends DeleteArea implements IFlyout { // Fire a VarCreate event for each (if any) new variable created. for (let i = 0; i < newVariables.length; i++) { const thisVariable = newVariables[i]; - eventUtils.fire(new (eventUtils.get(eventUtils.VAR_CREATE))! - (thisVariable)); + eventUtils.fire( + new (eventUtils.get(eventUtils.VAR_CREATE))(thisVariable)); } // Block events come after var events, in case they refer to newly created // variables. - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))!(newBlock)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(newBlock)); } if (this.autoClose) { this.hide(); diff --git a/core/gesture.ts b/core/gesture.ts index ab877eed8..9ec0d17fd 100644 --- a/core/gesture.ts +++ b/core/gesture.ts @@ -625,8 +625,8 @@ export class Gesture { * @param ws The workspace that a user clicks on. */ private fireWorkspaceClick_(ws: WorkspaceSvg) { - eventUtils.fire(new (eventUtils.get(eventUtils.CLICK))! - (null, ws.id, 'workspace')); + eventUtils.fire( + new (eventUtils.get(eventUtils.CLICK))(null, ws.id, 'workspace')); } /** @@ -712,8 +712,8 @@ export class Gesture { } } else { // Clicks events are on the start block, even if it was a shadow. - const event = new (eventUtils.get(eventUtils.CLICK))! - (this.startBlock_, this.startWorkspace_.id, 'block'); + const event = new (eventUtils.get(eventUtils.CLICK))( + this.startBlock_, this.startWorkspace_.id, 'block'); eventUtils.fire(event); } this.bringBlockToFront_(); diff --git a/core/mutator.ts b/core/mutator.ts index 27404ff3b..11843577f 100644 --- a/core/mutator.ts +++ b/core/mutator.ts @@ -301,8 +301,8 @@ export class Mutator extends Icon { // No change. return; } - eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))! - (this.block_, visible, 'mutator')); + eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))( + this.block_, visible, 'mutator')); if (visible) { // Create the bubble. this.bubble_ = new Bubble( @@ -460,7 +460,7 @@ export class Mutator extends Icon { const newExtraState = BlockChange.getExtraBlockState_(block); if (oldExtraState !== newExtraState) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))!( + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( block, 'mutation', null, oldExtraState, newExtraState)); // Ensure that any bump is part of this mutation's event group. const mutationGroup = eventUtils.getGroup(); diff --git a/core/procedures.ts b/core/procedures.ts index 8f6baf2cf..fe3cc4016 100644 --- a/core/procedures.ts +++ b/core/procedures.ts @@ -423,8 +423,8 @@ export function mutateCallers(defBlock: Block) { // undo action since it is deterministically tied to the procedure's // definition mutation. eventUtils.setRecordUndo(false); - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))! - (caller, 'mutation', null, oldMutation, newMutation)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CHANGE))( + caller, 'mutation', null, oldMutation, newMutation)); eventUtils.setRecordUndo(oldRecordUndo); } } diff --git a/core/renderers/common/marker_svg.ts b/core/renderers/common/marker_svg.ts index 8710fc69a..bf63f1b7e 100644 --- a/core/renderers/common/marker_svg.ts +++ b/core/renderers/common/marker_svg.ts @@ -562,8 +562,8 @@ export class MarkerSvg { */ private fireMarkerEvent_(oldNode: ASTNode, curNode: ASTNode) { const curBlock = curNode.getSourceBlock(); - const event = new (eventUtils.get(eventUtils.MARKER_MOVE))! - (curBlock, this.isCursor(), oldNode, curNode); + const event = new (eventUtils.get(eventUtils.MARKER_MOVE))( + curBlock, this.isCursor(), oldNode, curNode); eventUtils.fire(event); } diff --git a/core/serialization/blocks.ts b/core/serialization/blocks.ts index 1551ff705..4bc96fe86 100644 --- a/core/serialization/blocks.ts +++ b/core/serialization/blocks.ts @@ -361,7 +361,7 @@ export function appendInternal( const block = appendPrivate(state, workspace, {parentConnection, isShadow}); eventUtils.enable(); - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))!(block)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(block)); eventUtils.setGroup(existingGroup); eventUtils.setRecordUndo(prevRecordUndo); diff --git a/core/serialization/workspaces.ts b/core/serialization/workspaces.ts index 2a123a719..9d8e857ef 100644 --- a/core/serialization/workspaces.ts +++ b/core/serialization/workspaces.ts @@ -96,8 +96,7 @@ export function load( } dom.stopTextWidthCache(); - eventUtils.fire(new (eventUtils.get(eventUtils.FINISHED_LOADING))! - (workspace)); + eventUtils.fire(new (eventUtils.get(eventUtils.FINISHED_LOADING))(workspace)); eventUtils.setGroup(existingGroup); eventUtils.setRecordUndo(prevRecordUndo); diff --git a/core/toolbox/toolbox.ts b/core/toolbox/toolbox.ts index 8368e9094..4c94b056f 100644 --- a/core/toolbox/toolbox.ts +++ b/core/toolbox/toolbox.ts @@ -928,8 +928,8 @@ export class Toolbox extends DeleteArea implements IAutoHideable, if (oldItem === newItem) { newElement = null; } - const event = new (eventUtils.get(eventUtils.TOOLBOX_ITEM_SELECT))! - (oldElement, newElement, this.workspace_.id); + const event = new (eventUtils.get(eventUtils.TOOLBOX_ITEM_SELECT))( + oldElement, newElement, this.workspace_.id); eventUtils.fire(event); } diff --git a/core/trashcan.ts b/core/trashcan.ts index 8078432a4..742065393 100644 --- a/core/trashcan.ts +++ b/core/trashcan.ts @@ -503,8 +503,8 @@ export class Trashcan extends DeleteArea implements IAutoHideable, * @param trashcanOpen Whether the flyout is opening. */ private fireUiEvent_(trashcanOpen: boolean) { - const uiEvent = new (eventUtils.get(eventUtils.TRASHCAN_OPEN))! - (trashcanOpen, this.workspace.id); + const uiEvent = new (eventUtils.get(eventUtils.TRASHCAN_OPEN))( + trashcanOpen, this.workspace.id); eventUtils.fire(uiEvent); } diff --git a/core/variable_map.ts b/core/variable_map.ts index 061b0eaa3..f2dd95edb 100644 --- a/core/variable_map.ts +++ b/core/variable_map.ts @@ -103,8 +103,8 @@ export class VariableMap { */ private renameVariableAndUses_( variable: VariableModel, newName: string, blocks: Block[]) { - eventUtils.fire(new (eventUtils.get(eventUtils.VAR_RENAME))! - (variable, newName)); + eventUtils.fire( + new (eventUtils.get(eventUtils.VAR_RENAME))(variable, newName)); variable.name = newName; for (let i = 0; i < blocks.length; i++) { blocks[i].updateVarName(variable); @@ -139,7 +139,7 @@ export class VariableMap { blocks[i].renameVarById(variable.getId(), conflictVar.getId()); } // Finally delete the original variable, which is now unreferenced. - eventUtils.fire(new (eventUtils.get(eventUtils.VAR_DELETE))!(variable)); + eventUtils.fire(new (eventUtils.get(eventUtils.VAR_DELETE))(variable)); // And remove it from the list. arrayUtils.removeElem(this.variableMap.get(type)!, variable); } @@ -200,8 +200,8 @@ export class VariableMap { const tempVar = variableList[i]; if (tempVar.getId() === variableId) { variableList.splice(i, 1); - eventUtils.fire(new (eventUtils.get(eventUtils.VAR_DELETE))! - (variable)); + eventUtils.fire( + new (eventUtils.get(eventUtils.VAR_DELETE))(variable)); return; } } diff --git a/core/variable_model.ts b/core/variable_model.ts index dc72094dd..cd404d316 100644 --- a/core/variable_model.ts +++ b/core/variable_model.ts @@ -59,7 +59,7 @@ export class VariableModel { */ this.id_ = opt_id || idGenerator.genUid(); - eventUtils.fire(new (eventUtils.get(eventUtils.VAR_CREATE))!(this)); + eventUtils.fire(new (eventUtils.get(eventUtils.VAR_CREATE))(this)); } /** @returns The ID for the variable. */ diff --git a/core/warning.ts b/core/warning.ts index 80706936f..d02eba5b8 100644 --- a/core/warning.ts +++ b/core/warning.ts @@ -88,8 +88,8 @@ export class Warning extends Icon { if (visible === this.isVisible()) { return; } - eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))! - (this.block_, visible, 'warning')); + eventUtils.fire(new (eventUtils.get(eventUtils.BUBBLE_OPEN))( + this.block_, visible, 'warning')); if (visible) { this.createBubble_(); } else { diff --git a/core/workspace_comment.ts b/core/workspace_comment.ts index 449116f3d..9838d1139 100644 --- a/core/workspace_comment.ts +++ b/core/workspace_comment.ts @@ -97,7 +97,7 @@ export class WorkspaceComment { } if (eventUtils.isEnabled()) { - eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_DELETE))!(this)); + eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_DELETE))(this)); } // Remove from the list of top comments and the comment database. this.workspace.removeTopComment(this); @@ -167,7 +167,7 @@ export class WorkspaceComment { */ moveBy(dx: number, dy: number) { const event = - new (eventUtils.get(eventUtils.COMMENT_MOVE))!(this) as CommentMove; + new (eventUtils.get(eventUtils.COMMENT_MOVE))(this) as CommentMove; this.xy_.translate(dx, dy); event.recordNew(); eventUtils.fire(event); @@ -252,8 +252,8 @@ export class WorkspaceComment { */ setContent(content: string) { if (this.content_ !== content) { - eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_CHANGE))! - (this, this.content_, content)); + eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_CHANGE))( + this, this.content_, content)); this.content_ = content; } } @@ -314,8 +314,8 @@ export class WorkspaceComment { eventUtils.setGroup(true); } try { - eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_CREATE))! - (comment)); + eventUtils.fire( + new (eventUtils.get(eventUtils.COMMENT_CREATE))(comment)); } finally { if (!existingGroup) { eventUtils.setGroup(false); diff --git a/core/workspace_comment_svg.ts b/core/workspace_comment_svg.ts index 6efcc1143..769a4f707 100644 --- a/core/workspace_comment_svg.ts +++ b/core/workspace_comment_svg.ts @@ -146,7 +146,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements } if (eventUtils.isEnabled()) { - eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_DELETE))!(this)); + eventUtils.fire(new (eventUtils.get(eventUtils.COMMENT_DELETE))(this)); } dom.removeNode(this.svgGroup_); @@ -234,8 +234,8 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements eventUtils.enable(); } } - const event = new (eventUtils.get(eventUtils.SELECTED))! - (oldId, this.id, this.workspace.id); + const event = new (eventUtils.get(eventUtils.SELECTED))( + oldId, this.id, this.workspace.id); eventUtils.fire(event); common.setSelected(this); this.addSelect(); @@ -250,8 +250,8 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements if (common.getSelected() !== this) { return; } - const event = new (eventUtils.get(eventUtils.SELECTED))! - (this.id, null, this.workspace.id); + const event = new (eventUtils.get(eventUtils.SELECTED))( + this.id, null, this.workspace.id); eventUtils.fire(event); common.setSelected(null); this.removeSelect(); @@ -350,7 +350,7 @@ export class WorkspaceCommentSvg extends WorkspaceComment implements */ override moveBy(dx: number, dy: number) { const event = - new (eventUtils.get(eventUtils.COMMENT_MOVE))!(this) as CommentMove; + new (eventUtils.get(eventUtils.COMMENT_MOVE))(this) as CommentMove; // TODO: Do I need to look up the relative to surface XY position here? const xy = this.getRelativeToSurfaceXY(); this.translate(xy.x + dx, xy.y + dy); diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 00310779e..7e4186b43 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -577,8 +577,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { this.setVisible(true); } - const event = new (eventUtils.get(eventUtils.THEME_CHANGE))! - (this.getTheme().name, this.id); + const event = new (eventUtils.get(eventUtils.THEME_CHANGE))( + this.getTheme().name, this.id); eventUtils.fire(event); } @@ -1141,8 +1141,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { // of negligible changes in viewport top/left. return; } - const event = new (eventUtils.get(eventUtils.VIEWPORT_CHANGE))! - (top, left, scale, this.id, this.oldScale_); + const event = new (eventUtils.get(eventUtils.VIEWPORT_CHANGE))( + top, left, scale, this.id, this.oldScale_); this.oldScale_ = scale; this.oldTop_ = top; this.oldLeft_ = left; @@ -1469,7 +1469,7 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg { eventUtils.enable(); } if (eventUtils.isEnabled() && !block!.isShadow()) { - eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))!(block!)); + eventUtils.fire(new (eventUtils.get(eventUtils.BLOCK_CREATE))(block!)); } block!.select(); return block!; diff --git a/core/xml.ts b/core/xml.ts index ff81aac55..19443453a 100644 --- a/core/xml.ts +++ b/core/xml.ts @@ -503,8 +503,7 @@ export function domToWorkspace(xml: Element, workspace: Workspace): string[] { if ((workspace as WorkspaceSvg).setResizesEnabled) { (workspace as WorkspaceSvg).setResizesEnabled(true); } - eventUtils.fire(new (eventUtils.get(eventUtils.FINISHED_LOADING))! - (workspace)); + eventUtils.fire(new (eventUtils.get(eventUtils.FINISHED_LOADING))(workspace)); return newBlockIds; } @@ -618,12 +617,12 @@ export function domToBlock(xmlBlock: Element, workspace: Workspace): Block { // Fire a VarCreate event for each (if any) new variable created. for (let i = 0; i < newVariables.length; i++) { const thisVariable = newVariables[i]; - eventUtils.fire(new (eventUtils.get(eventUtils.VAR_CREATE))! - (thisVariable)); + eventUtils.fire( + new (eventUtils.get(eventUtils.VAR_CREATE))(thisVariable)); } // Block events come after var events, in case they refer to newly created // variables. - eventUtils.fire(new (eventUtils.get(eventUtils.CREATE))!(topBlock)); + eventUtils.fire(new (eventUtils.get(eventUtils.CREATE))(topBlock)); } return topBlock; } diff --git a/core/zoom_controls.ts b/core/zoom_controls.ts index 5098487e2..37c441ed1 100644 --- a/core/zoom_controls.ts +++ b/core/zoom_controls.ts @@ -414,8 +414,8 @@ export class ZoomControls implements IPositionable { /** Fires a zoom control UI event. */ private fireZoomEvent_() { - const uiEvent = new (eventUtils.get(eventUtils.CLICK))! - (null, this.workspace.id, 'zoom_controls'); + const uiEvent = new (eventUtils.get(eventUtils.CLICK))( + null, this.workspace.id, 'zoom_controls'); eventUtils.fire(uiEvent); } }