Write clearer code with TypeScript 4.0

Write clearer code with TypeScript 4.0

Microsoft’s open source JavaScript superset gets a big update, making it easier to write complex applications for the Web

We probably shouldn’t be surprised that JavaScript has become one of the most popular programming languages in use today. It’s powerful, flexible, and easy to learn. But it still has issues, especially around how it handles types. It’s difficult to write large, complex applications in JavaScript because it’s hard to validate code before it runs. It’s tough to use in-line code analysis tools when using dynamic typing, reducing the effectiveness of tools such as Visual Studio’s IntelliSense.

Without static types, it’s hard to recommend JavaScript as a language for building large-scale applications. You certainly wouldn’t want to use it for applications such as Office or to build complex programmers’ editors. But JavaScript is an extensible language with runtimes for many different platforms, so it’s an attractive target for developers who don’t want to spend time writing different versions of their code for different environments. One option is technologies such as transpilers, which make it possible to compile code from other languages to JavaScript.

Also on InfoWorld: TypeScript vs. JavaScript: Understand the differences ]

TypeScript: a strongly typed alternative to JavaScript

That’s the approach taken by Microsoft’s TypeScript languageDeveloped as a strongly typed superset of JavaScript, it’s designed to build on JavaScript to deliver a language that could be used for those large-scale development projects, helping manage the many hundreds and thousands of variables in your code and allowing in-line code analysis and debugging tools to help you write code correctly. You can add existing JavaScript code to a TypeScript application and it’ll run without needing any changes, making it relatively easy to start the process of converting dynamic typed code to TypeScript’s strict static typing.

Nearly eight years ago Microsoft released the first public build, 0.8.1, of TypeScript, in November 2012. Since then it’s been used on many large-scale Web applications and in many apps running on the Electron cross-platform runtime. You’ve probably used one without realizing it, perhaps reading your e-mail on Outlook.com or working on some code in Visual Studio Code. One of Microsoft’s biggest open source projects, it’s led the way for the open sourcing of .NET and much of the current open design and development model used across the company. Now the latest version has been released, Version 4.0, with a significant number of improvements and new features.

Getting started with TypeScript 4.0

Microsoft’s philosophy with TypeScript has been to avoid breaking changes, so existing TypeScript applications can be transpiled with the new TypeScript tooling. All you need to do is upgrade using NuGet or npm to use it in any development environment that supports TypeScript. Microsoft offers deep integration in Visual Studio with a TypeScript 4.0 plug-in in the Visual Studio Marketplace that adds support for in-editor debugging and a command line compiler.

If you’re using Visual Studio Code you automatically get support for the newest release in an upcoming update, as it ships with a recent stable version. If you want the new TypeScript right away, you can either download an Insider Build of Visual Studio Code, switch to the nightly build of TypeScript from the Code command line, or add an updated TypeScript version number to your code and switch the workspace version in use.

This last approach might be your best option, as it lets you keep TypeScript 4.0 code separate from other versions you might need to maintain before upgrading. You may need to download an updated language server definition using npm and update your TypeScript user settings if you intend to make TypeScript 4.0 your default.

code visual studio code visual studio

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

COMO USAR e trabalhar com Code Review no Visual Studio Code

💲 Live CollabPlay: https://youtu.be/B6LCFSPdsE0 💲 Hospedagem com Desconto Exclusivo: https://tekers.tech/4e587 Não é todo programador que gosta de compartilh...

User Snippets (Code Shortcuts) in Visual Studio Code

#vscode Hello, my friends and fellow developers, this video is all about User Snippets. That means the Snippets (Code Shortcuts) that you can make for yourse...

Python в Visual Studio Code

We are pleased to announce that the July release of the Python extension is now available for Visual Studio Code. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can read more about Python support in Visual Studio Code in the documentation .

C++ Development with Visual Studio Code

If you’re looking for a fast and lightweight open-source code editor, Visual Studio Code has you covered. Come for a deep dive into the features of Visual Studio Code which provide a rich, productive environment for C++ development.

The History of Visual Studio Code

We speak to the creator of Visual Studio Code about the early challenges to now becoming the most popular development environment in the world.