import Blockly from 'blockly';

interface Init {
  init(): void;
}

/**
 * Blockly.Blocks[name] = factory
 */
export function def<T>(name: string, init: T & Init & ThisType<T & Blockly.Block>) {
  Blockly.Blocks[name] = init;
}

/**
 * Blockly.Blocks のエイリアス
 */
export const Blocks = Blockly.Blocks as { [key: string]: Init & ThisType<Init & Blockly.Block> };
