microsoft / microsoft/pxt

Dynamic enum values lost when editing code

Open
#10,239 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Dynamic enum values reset to 0 once a change was made in the code.

To Reproduce

  1. Go to https://makecode.com/playground#language-create-enums
  2. Click 'Run'
  3. Add a 'Show $color' block from the 'Language' menu and give it a non-zero value (Blue or Yellow)
    4.Switch to the JavaScript view
  4. Add an empty line at the end of the code
  5. Switch back to Blocks view
  6. The block displays the value Red (0), while the code shows otherwise
  7. When in actual projects, saving and reloading resets the value to 0 also in the code view resulting in real data loss
    Expected behavior
  8. Blocks and code values should be in sync
  9. Values should not be lost after reload

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 reproducing the issue in the linked MakeCode enum playground, comparing the Blocks and JavaScript views after changing a dynamic enum value and reloading. Trace the code that serializes and restores enum values during the Blocks/JavaScript transition and project reload. Done means non-zero values remain synchronized in both views and survive saving and reloading.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.