TypeScript
Type annotations are erased first, then the code goes to the JavaScript backend: a JS subset with a typed shell.
How to run it on your phone
vml run examples/typescript/school/binary_search.ts
Compiling takes a while (one to two minutes for C, a few seconds for scripting languages). Once the program is running, the gamepad is at the bottom of the screen - the D-pad and the four action buttons are all there. Tap the back arrow in the top-right corner to return to the Shell.
What to know before you write
- Type annotations,
interface,type,enumandasall work; erasure does not change runtime behaviour - Object fields (
p.name) are printed as integers for now: do not expect strings for...ofand class instance method calls do not compile: JS-subset limits, not TS ones- After defining
function main()remember to call it once
Examples
| File | What it shows |
|---|
Also in this folder: school/NOTICE.md, school/README.md, school/binary_search.ts, school/bubble_sort.ts, school/class_demo.ts, school/fibonacci.ts, school/fizzbuzz.ts, school/hanoi.ts, school/palindrome.ts, school/types_demo.ts
The rest of this page is taken straight from the VML source (third_party/vml/VMLPrepares/TypeScriptCompiler/): the README covers what this front end supports and how to compile it, and the language reference covers the syntax itself. When upstream changes, regenerating this page brings it up to date.
Language reference
This reference section is not available in English yet. The English twin of the upstream document (
TYPESCRIPT_LANGUAGE_SPEC.en.md) has not been written, so it is not shown here. The original lives in the app's source atthird_party/vml/VMLPrepares/TypeScriptCompiler/TYPESCRIPT_LANGUAGE_SPEC.md.
Compiler README
This reference section is not available in English yet. The English twin of the upstream document (
README.en.md) has not been written, so it is not shown here. The original lives in the app's source atthird_party/vml/VMLPrepares/TypeScriptCompiler/README.md.