microsoft / microsoft/pxt

number.toString() doesnt support a radix argument.

Open
#5,957 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug
The number.toString() function, should be able to have the argument "radix" when you try this on
the micro:bit makecode website, it will produce this error:
error TS2554: Expected 0 arguments, but got 1.
In actual javascript, you should be able to use this function with an argument.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString

To Reproduce
Goto the javascript editor on makecode, and try the following:
basic.showString(11.toString(2))

Expected behavior
convert 11 to binary and, show the string "1011" on the screen.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: 77.0.3865.90 64 bit

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 in the MakeCode JavaScript editor with basic.showString(11.toString(2), and inspect how Number.toString is typed and handled there. Confirm the change by checking that the example compiles and displays "1011" on the micro:bit simulator or device.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
developer-experience
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.