Skip to content

Allow pxt.json to append to the runtime.functionOptions.extraFunctionEditorTypes array #10830

@Parakleta

Description

@Parakleta

Is your feature request related to a problem? Please describe.

I'm trying to teach good problem decomposition using functions and classes. As a scaffolding step I want to provide the class definitions for students, as well as template code, and have students populate a function with their implementation to explore possible solutions.

Unfortunately at this stage it is not possible to have blockly functions take custom classes as argument types.

Describe the solution you'd like

In the same way that pxt-microbit/pxtarget.json is able to populate the runtime.functionOptions.extraFunctionEditorTypes field to add sprites and images, I would like my own projects/extensions to be able to add a field to the pxt.json file to extend this extraFunctionEditorTypes array to make my own custom classes available as function arguments.

Describe alternatives you've considered

It is possible to 'kludge' around this by always passing an array of 1 element of the custom type, but this is clumsy and not the correct way to use a type-checked language like typescript. It could also potentially lead to confusion if any students "peek under the hood".

I am also concerned that due to type inference mechanisms around arrays a student may get into a situation where, due to mismatched types (an accidental placement of a block in the wrong context), the student becomes confused and unable to proceed with the activity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions