fix: make eventUtils throw if event type not registered (#6381)

* chore: update lint rules

* fix: have eventUtils.get throw if event isn't found

* chore: remove nonnull assertion from eventUtils.get and format
This commit is contained in:
Maribeth Bottorff
2022-08-24 13:41:32 -07:00
committed by GitHub
parent 980fe138e7
commit 60bc01acc8
29 changed files with 98 additions and 94 deletions

View File

@@ -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;
}