From a0c0b8667975f40dbfed7310bd7c42a38a63796e Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Wed, 7 Oct 2020 11:04:10 -0700 Subject: [PATCH] Fix toolbox types (#4355) --- core/toolbox/category.js | 16 +++++++-------- core/toolbox/separator.js | 2 +- core/toolbox/toolbox.js | 2 +- core/utils/toolbox.js | 43 ++++++++++++++++++++------------------- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/core/toolbox/category.js b/core/toolbox/category.js index cd77da7fe..201bbba66 100644 --- a/core/toolbox/category.js +++ b/core/toolbox/category.js @@ -121,14 +121,14 @@ Blockly.utils.object.inherits(Blockly.ToolboxCategory, Blockly.ToolboxItem); /** * All the css class names that are used to create a category. * @typedef {{ - * container:?string, - * row:?string, - * rowcontentcontainer:?string, - * icon:?string, - * label:?string, - * selected:?string, - * openicon:?string, - * closedicon:?string + * container:(string|undefined), + * row:(string|undefined), + * rowcontentcontainer:(string|undefined), + * icon:(string|undefined), + * label:(string|undefined), + * selected:(string|undefined), + * openicon:(string|undefined), + * closedicon:(string|undefined) * }} */ Blockly.ToolboxCategory.CssConfig; diff --git a/core/toolbox/separator.js b/core/toolbox/separator.js index bac8a5e27..2c51cd4a0 100644 --- a/core/toolbox/separator.js +++ b/core/toolbox/separator.js @@ -53,7 +53,7 @@ Blockly.utils.object.inherits(Blockly.ToolboxSeparator, Blockly.ToolboxItem); /** * All the css class names that are used to create a separator. * @typedef {{ - * container:?string + * container:(string|undefined) * }} */ Blockly.ToolboxSeparator.CssConfig; diff --git a/core/toolbox/toolbox.js b/core/toolbox/toolbox.js index 5b8cc5b4b..f5b023d95 100644 --- a/core/toolbox/toolbox.js +++ b/core/toolbox/toolbox.js @@ -386,7 +386,7 @@ Blockly.Toolbox.prototype.renderContents_ = function(toolboxDef) { /** * Creates and renders the toolbox item. - * @param {Blockly.utils.toolbox.ToolboxItemInfo} toolboxItemDef Any information + * @param {!Blockly.utils.toolbox.ToolboxItemInfo} toolboxItemDef Any information * that can be used to create an item in the toolbox. * @param {!DocumentFragment} fragment The document fragment to add the child * toolbox elements to. diff --git a/core/utils/toolbox.js b/core/utils/toolbox.js index 27b76b262..1defda31c 100644 --- a/core/utils/toolbox.js +++ b/core/utils/toolbox.js @@ -20,10 +20,10 @@ goog.requireType('Blockly.ToolboxSeparator'); * The information needed to create a block in the toolbox. * @typedef {{ * kind:string, - * blockxml:(?string|Node), - * type: ?string, - * gap: (?string|?number), - * disabled: (?string|?boolean) + * blockxml:(string|!Node|undefined), + * type:(string|undefined), + * gap:(string|number|undefined), + * disabled: (string|boolean|undefined) * }} */ Blockly.utils.toolbox.BlockInfo; @@ -32,9 +32,9 @@ Blockly.utils.toolbox.BlockInfo; * The information needed to create a separator in the toolbox. * @typedef {{ * kind:string, - * id:?string, - * gap:?number, - * cssconfig:?Blockly.ToolboxSeparator.CssConfig + * id:(string|undefined), + * gap:(number|undefined), + * cssconfig:(!Blockly.ToolboxSeparator.CssConfig|undefined) * }} */ Blockly.utils.toolbox.SeparatorInfo; @@ -53,8 +53,8 @@ Blockly.utils.toolbox.ButtonInfo; * The information needed to create a label in the toolbox. * @typedef {{ * kind:string, - * id:?string, - * text:string + * text:string, + * id:(string|undefined) * }} */ Blockly.utils.toolbox.LabelInfo; @@ -71,12 +71,12 @@ Blockly.utils.toolbox.ButtonOrLabelInfo; * @typedef {{ * kind:string, * name:string, - * id:?string, - * categorystyle:?string, - * colour:?string, - * cssconfig:?Blockly.ToolboxCategory.CssConfig, - * contents:!Array, - * hidden:?string + * contents:!Array, + * id:(string|undefined), + * categorystyle:(string|undefined), + * colour:(string|undefined), + * cssconfig:(!Blockly.ToolboxCategory.CssConfig|undefined), + * hidden:(string|undefined) * }} */ Blockly.utils.toolbox.StaticCategoryInfo; @@ -86,11 +86,11 @@ Blockly.utils.toolbox.StaticCategoryInfo; * @typedef {{ * kind:string, * custom:string, - * id:?string, - * categorystyle:?string, - * colour:?string, - * cssconfig:?Blockly.ToolboxCategory.CssConfig, - * hidden:?string + * id:(string|undefined), + * categorystyle:(string|undefined), + * colour:(string|undefined), + * cssconfig:(!Blockly.ToolboxCategory.CssConfig|undefined), + * hidden:(string|undefined) * }} */ Blockly.utils.toolbox.DynamicCategoryInfo; @@ -122,7 +122,8 @@ Blockly.utils.toolbox.FlyoutItemInfo; /** * The JSON definition of a toolbox. * @typedef {{ - * contents:!Array + * kind:(string|undefined), + * contents:!Array * }} */ Blockly.utils.toolbox.ToolboxInfo;