microsoft / microsoft/pxt-microbit
Cast to class or interface
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
Describe the bug
In PXT 4.4, cast to class or interface is not supported.

In PXT 5.5, no error is displayed on the JavaScript editor but the code does not run.


To Reproduce
Steps to reproduce the behavior:
- Go to https://makecode.microbit.org/beta
- Switch to JavaScript
- Paste the code below to the editor
interface Length {
length: number;
}
function showLength(x: Length) {
basic.showNumber(x.length);
}
showLength([]);
showLength("X");
- See error
Expected behavior
Either the cast is disallowed with error or it works successfully.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the JavaScript editor in the PXT micro:bit beta and reproduce the issue with the provided Length interface, showLength function, and calls using [] and "X". Trace whether the invalid cast is diagnosed or reaches runtime; done means the code is consistently rejected with an error or executes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100