Issue
How can I run TypeScript programs using a Android phone? Are there any apps available to run TypeScript programs offline on Android?
Solution
You can run TypeScript programs on Android using Termux. Follow these steps to run TypeScript in Termux.
Install Termux app from Play Store.
Install Node.js package in termux using the command
pkg install nodejs
Install TypeScript node module on Termux using command
npm install typescript
Install code editor like Micro using command
pkg install micro
. You can also use any code editor apps like Acode or Spck.Create a TypeScript file using command
micro hello.ts
This will open a editor where you can write your TypeScript code. If you are writing the program using external code editor apps, change the working directory of Termux to the folder where you have saved your TypeScript program.After writing TypeScript code, come back to terminal and type
tsc hello.ts
this will compile your TypeScript to JavaScript and create hello.js file in the same directory.Now you can run the JavaScript file using command
node hello.js
and it will show output of the code.
For shortcut, you can combine step 6 & 7 commands and use it like tsc hello.ts && node hello.js
Answered By - Bibek Oli Answer Checked By - Gilberto Lyons (WPSolving Admin)