Running TypeScript The Easy Way
If you’re a developer who is looking to use TypeScript in your projects, you might be wondering about the best way to run and compile your TypeScript code. Luckily, there are several easy methods to get started with TypeScript that won’t require a lot of setup or configuration.
Using Online Editors
One of the easiest ways to run TypeScript code is to use online code editors that support TypeScript. Websites like CodePen, JSFiddle, and TypeScript Playground allow you to write TypeScript code directly in your browser, and see the compiled JavaScript output in real-time.
These online editors are a great option for quickly prototyping or testing out small snippets of TypeScript code, without needing to set up a development environment on your local machine.
Using Code Editors with TypeScript Support
If you prefer to work in a more traditional development environment, many code editors like Visual Studio Code, Sublime Text, and Atom have built-in support for TypeScript. These editors can provide syntax highlighting, autocomplete suggestions, and error checking for your TypeScript code, making it easier to write and debug your programs.
With a few additional plugins or extensions, you can also set up automatic compilation of your TypeScript code into JavaScript whenever you save a file, eliminating the need to manually run the TypeScript compiler each time you make a change.
Using Node.js and the TypeScript Compiler
If you prefer to have more control over the compilation process, you can install Node.js and the TypeScript compiler on your machine. This will allow you to run the TypeScript compiler from the command line, and customize the compilation settings to suit your needs.
To get started with this method, you’ll need to install Node.js from the official website, and then use the npm package manager to install the TypeScript compiler globally with the command:
npm install -g typescript
Once you have TypeScript installed, you can compile your TypeScript code into JavaScript with the command:
tsc your-typescript-file.ts
This will generate a corresponding JavaScript file that you can run using Node.js or in a browser environment.
Conclusion
Regardless of which method you choose, getting started with TypeScript doesn’t have to be difficult. With the right tools and a bit of practice, you can quickly start writing and running TypeScript code in a way that suits your workflow and preferences.
Bun is waving 🙂
Cool
thank you. very cool 🙂
What's the name of terminal?
where is deno and justjs ? :/
Or save yourself the trouble and scalablity issues and use a build tool like Vite.
Was already typing my comment when you said "deno" hahaha
Why still no one talking about deno !!
Awesome, never knew this
node —experimental-loaders ts-node/esm file.ts
Deno?
Whats the theme you’re using, it looks awesome
Hi! What is this font you are using in terminal? I see that in code it's JetBrains Mono, but the terminal's font looks different
What's the theme name btw? ❤
I'd use ts-node-dev before ts-node tbh.
Ts-node sucks I suggest tsx
What is the font name ?
How does your terminal suggest commands or shows the history?
tsx is the best out of the bunch, there’s a comparison in its readme and it’s the most feature complete
I NEED THAT VSCODE THEME