microsoft / microsoft/pxt

Cannot define blocks with group in existing category, say 'Math', and specify group order?

Open
#4,003 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component: toolbox enhancement
Dominant language
TypeScript
Stars
2.3k
Forks
641
Avg merge
12h 4m
Merged PRs (30d)
57

Description

The groups attribute on an already existing namespace block category does not get applied to the existing category definition.

For example, if a target defines additional blocks in category Math using the usual namespace declaration, the attribute 'groups' does not seem to be applied to the existing category definition.

For example in the marked up declarations below the intent is to have the Vector group be below the built-in blocks that already exist in category Math.

Is there another way to do this?

//% groups='["other", "Vector"]'
declare namespace math {
    /**
     * Create vector.
     * @param x number, eg: 0
     * @param y number, eg: 0
     * @param z number, eg: 0
     */
    //% blockId="vector"
    //% block="X %x|Y %y|Z %z"
    //% group="Vector"
    //% shim=math3d::vector
    function vector(x?: number, y?: number, z?: number): Vector;

    /**
     * Unit vector.
     */
    //% blockId="vector_unit"
    //% block="unit vector"
    //% group="Vector"
    //% shim=math3d::unitVector
    function unitVector(): Vector;

    /**
     * Convert degress to radians.
     * @param degrees number, e.g. 0
     */
    //% blockId=convert_deg_to_rad
    //% block="%degrees degrees in radians"
    //% shim=math::degreesInRadians
    //% advanced=true
    function degreesInRadians(degrees: number): number;

    /**
     * Convert radians to degrees.
     * @param radians number, e.g. 0
     */
    //% blockId=convert_rad_to_deg
    //% block="%radians radians in degrees"
    //% shim=math::radiansInDegrees
    //% advanced=true
    function radiansInDegrees(radians: number): number;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the TypeScript namespace declaration and its groups attribute are processed for an existing category such as Math. Confirm that the Vector group is ordered below the built-in Math blocks, while the other declarations retain their stated grouping.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.