@@ -58,7 +58,7 @@ export interface Parameter {
5858 type ?: string ;
5959}
6060
61- export type ClassMethodDefBlock = Blockly . Block & ClassMethodDefMixin & Blockly . BlockSvg ;
61+ export type ClassMethodDefBlock = Blockly . Block & ClassMethodDefMixin ;
6262interface ClassMethodDefMixin extends ClassMethodDefMixinType {
6363 mrcMethodId : string ,
6464 mrcCanChangeSignature : boolean ,
@@ -182,12 +182,18 @@ const CLASS_METHOD_DEF = {
182182 if ( this . mrcCanChangeSignature ) {
183183 const nameField = new Blockly . FieldTextInput ( name ) ;
184184 input . insertFieldAt ( 0 , nameField , FIELD_METHOD_NAME ) ;
185- this . setMutator ( paramContainer . getMutatorIcon ( this ) ) ;
185+ if ( this . rendered ) {
186+ this . setMutator ( paramContainer . getMutatorIcon ( this as unknown as Blockly . BlockSvg ) ) ;
187+ }
186188 nameField . setValidator ( this . mrcNameFieldValidator . bind ( this , nameField ) ) ;
187189 } else {
188190 input . insertFieldAt ( 0 , createFieldNonEditableText ( name ) , FIELD_METHOD_NAME ) ;
189- // Case because a current bug in blockly where it won't allow passing null to Blockly.Block.setMutator makes it necessary.
190- ( this as Blockly . BlockSvg ) . setMutator ( null ) ;
191+ // Block.setMutator is defined as setMutator(_mutator: MutatorIcon) and BlockSvg.setMutator
192+ // is defined as setMutator(mutator: MutatorIcon | null).
193+ // Therefore, to call setMutator(null), this must be casted to BlockSvg.
194+ if ( this . rendered ) {
195+ ( this as unknown as Blockly . BlockSvg ) . setMutator ( null ) ;
196+ }
191197 }
192198 this . mrcUpdateParams ( ) ;
193199 this . mrcUpdateReturnInput ( ) ;
@@ -231,7 +237,9 @@ const CLASS_METHOD_DEF = {
231237 * mrcOnMutatorOpen is called when the mutator on a ClassMethodDefBlock is opened.
232238 */
233239 mrcOnMutatorOpen : function ( this : ClassMethodDefBlock ) : void {
234- paramContainer . onMutatorOpen ( this ) ;
240+ if ( this . rendered ) {
241+ paramContainer . onMutatorOpen ( this as unknown as Blockly . BlockSvg ) ;
242+ }
235243 } ,
236244 mrcRenameParameter : function ( this : ClassMethodDefBlock , oldName : string , newName : string ) {
237245 const nextBlock = this . getInputTargetBlock ( INPUT_STACK ) ;
0 commit comments