TypeScript SETUP by SilvenLEAF

Ahoy there! Let’s set up the environment for playing with TypeScript and learn how to run those TypeScript files!

Step 0: Install TypeScript

First let’s install TypeScript globally if you don’t have it yet.

npm i -g typescript

(By…


This content originally appeared on DEV Community and was authored by SilvenLEAF

Ahoy there! Let's set up the environment for playing with TypeScript and learn how to run those TypeScript files!

Step 0: Install TypeScript

First let's install TypeScript globally if you don't have it yet.

npm i -g typescript

(By the way, "npm i X" is the short-hand for "npm install X")

Now, let's create your project folder and open it in your beloved editor (mine VS Code)

Step 1: init tsconfig

Let's init the tsconfig file, type the following command

tsc --init

(This "tsc" command will only work if you have typescript globally installed)

It'll create a "tsconfig.json" file. Now, what does it do you ask? TypeScript is the superset of JavaScript and how we want to compile it will be defined by this tsconfig file. The best part is, it'll give you linting (the red lines whenever there is an error in your code or logic) and also explicitly tell you what mistakes you are doing and in some cases possible solutions as well. Amazing right?

Step 2: run TypeScript files

Now you created a TypeScript file, wrote your code, for example an app.ts file with this content

console.log('Hello there TypeScript! You are AMAIZING!!')

Now how to run this file? If it were a JavaScript file, like app.js, you might run "node app.js" or "nodemon app.js", right? So let's find the TypeScript versions for those!

Let's install the packages

npm i ts-node ts-node-dev

"ts-node" is the TypeScript version for "node" and "ts-node-dev" is the TypeScript version for "nodemon". So to run the TypeScript file use either of these commands

ts-node app.ts

(Which is basically "node app.js")

ts-node-dev app.ts

(Which is basically "nodemon app.js")

YIPPIE!! You just set up the environment for coding in TypeScript and also learnt how to run those FILES!! YOOOHOOOO!!! But now what?

What's NEXT?

1. Improved AI BOT that can do anything

2. Insane stuff with JavaScript/TypeScript

3. Debugging TypeScript with VS Code Debugger

4. How to automate anything

5. Sequelize Hooks

6. Automate creating DB Schemas

7. How to create an Android APP with NO XP

(including apk generating)

Got any doubt?

Drop a comment or Feel free to reach out to me @SilveLEAF on Twitter or Linkedin

Wanna know more about me? Come here!
SilvenLEAF.github.io


This content originally appeared on DEV Community and was authored by SilvenLEAF


Print Share Comment Cite Upload Translate Updates
APA

SilvenLEAF | Sciencx (2021-10-14T01:56:29+00:00) TypeScript SETUP by SilvenLEAF. Retrieved from https://www.scien.cx/2021/10/14/typescript-setup-by-silvenleaf/

MLA
" » TypeScript SETUP by SilvenLEAF." SilvenLEAF | Sciencx - Thursday October 14, 2021, https://www.scien.cx/2021/10/14/typescript-setup-by-silvenleaf/
HARVARD
SilvenLEAF | Sciencx Thursday October 14, 2021 » TypeScript SETUP by SilvenLEAF., viewed ,<https://www.scien.cx/2021/10/14/typescript-setup-by-silvenleaf/>
VANCOUVER
SilvenLEAF | Sciencx - » TypeScript SETUP by SilvenLEAF. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/14/typescript-setup-by-silvenleaf/
CHICAGO
" » TypeScript SETUP by SilvenLEAF." SilvenLEAF | Sciencx - Accessed . https://www.scien.cx/2021/10/14/typescript-setup-by-silvenleaf/
IEEE
" » TypeScript SETUP by SilvenLEAF." SilvenLEAF | Sciencx [Online]. Available: https://www.scien.cx/2021/10/14/typescript-setup-by-silvenleaf/. [Accessed: ]
rf:citation
» TypeScript SETUP by SilvenLEAF | SilvenLEAF | Sciencx | https://www.scien.cx/2021/10/14/typescript-setup-by-silvenleaf/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.