onConfirm_() {
    const text = this.getValidInput_();
    const type = this.getSelectedType_() || '';
    if (text) {
      const existing = Blockly.Variables.nameUsedWithAnyType(
        text,
        this.workspace_,
      );
      if (existing) {
        let msg = '';
        if (existing.type === type) {
          msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS'].replace(
            '%1',
            existing.name,
          );
        } else {
          msg = Blockly.Msg['VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE'];
          msg = msg
            .replace('%1', existing.name)
            .replace('%2', this.getDisplayName_(existing.type));
        }
        Blockly.dialog.alert(msg);
      } else {
        // No conflict
        this.workspace_.createVariable(text, type);
        this.hide();
      }
    } else {
      Blockly.dialog.alert(Blockly.Msg['TYPED_VAR_MODAL_INVALID_NAME']);
    }
  }
Get the function to be called when the user tries to create a variable.
@protected