mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
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:
committed by
GitHub
parent
980fe138e7
commit
60bc01acc8
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user