TypeScript is great for me and might be for you

Kelvne Pechim
Aug 23, 2017 · 3 min read

Esse artigo também está disponível em Português (https://medium.com/@kelvne.pechim/typescript-%C3%A9-incr%C3%ADvel-para-mim-e-talvez-seja-incr%C3%ADvel-para-voc%C3%AA-d5ef09a41781)

I’ve been programming for a long time. I remember my first programming classes in college and how I hated C, C++, Java, and other strongly typed languages. I was so naive. 😅

I already had some previous programming experience with weakly typed languages before college and I couldn’t understand why I would want to statically set a type to a variable or define an interface for a function.

Well… Maturity comes with experience. 😆

JavaScript is great! TypeScript is greater!

For the last three years I’ve been in touch with JavaScript daily. I feel really well working with it but its syntax has some downsides, in my humble opinion, that only a weakly typed language like JavaScript has.

JavaScript is great. It is an easy language. Which means that you can prototype applications really fast. The ecosystem is so big that there is a great amount of libraries and frameworks to build applications for different platforms.

TypeScript is greater because it is everything that JavaScript is and more. In some way, it fixed JavaScript for me.

I decided to give TypeScript a chance after I started studying Golang. — Me trying to convince my boss that TypeScript is awesome.

Golang 😍

Buffed JavaScript

TypeScript is not just a language that has seamless interoperability with JavaScript codebase. TypeScript replaces the need for Babel in most cases, it has a great linter, it has a beautiful auto-complete integration with Visual Studio Code and other IDEs. Moreover its strong typing capabilities makes programming much more pleasant and your code a lot more clean and easy to debug.

TypeScript is just a buffed version of JavaScript. — Me and a lot of other people.


Will be the future good?

Knowing what is going to happen is always good. I mean, in programming. Spoilers are bad. 😠

TypeScript will help you to prevent runtime errors. Because you can see the future! Check this out:

This is part of one of my upcoming projects.

Taking these functions as an example. Wherever I call this findPokemon function I know exactly it is going to return a Pokemon — Generics are awesome — . The Pokemon is defined by this interface:

export interface Pokemon {
id: number,
name: string,
sprite?: string,
};

So it is totally cool for me to use that function like this:

findPokemon(1)
.then((pokemon) => {
console.log(pokemon.name) // Logs out Bulbasaur
});

I don’t have to check if the Pokemon that is returned has a name property. I’m confident that it has because the TypeScript compiler doesn’t even build my project if I try to access a property that doesn’t exists in my interface or type.

No more runtime errors?

That doesn’t mean you won’t have runtime errors. When you read a JSON, for example, you can’t be sure of its data type so you’ll need to do some try/catch or any other type of error preventing techniques.


You probably won’t need Babel anymore

TypeScript is also the JavaScript from future. It already has a lot of features from ES6, ES7 and beyond… TypeScript even ships with JSX support! 😮(https://www.typescriptlang.org/docs/handbook/jsx.html)

TypeScript generates clean, readable and fast code. So it runs anywhere where JavaScript runs. It is totally configurable. Every TypeScript project has a tsconfig.json file. There you could even change the target ECMAScript version you want to generate after the build.


Try It!

It is really easy to start trying TypeScript. Since it has seamless interoperability with JavaScript code. You can just install TypeScript and create a tsconfig.json file inside your project’s root path and start typing.

For more information about installation: https://www.typescriptlang.org/

Pro Tip: For learning TypeScript while making great apps => ReactXP! (https://microsoft.github.io/reactxp/)

Written with much curiosity! — Pechim, K.

)

Kelvne Pechim

Written by

A kind of something that does things.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade