DEV Community

Discussion on: Is 2019 the year of TypeScript?

 
seangwright profile image
Sean G. Wright

Another nice thing about Typescript is how the types "flow" through the application.

Often I only need to annotate a couple of parameters, variables, methods.

Then when using those things the rest of my code is able to infer the results of operations.

For example:

function getName() {
  return 'lalo';
}

const name = getName();

Notice, there are 0 type annotations here...

But, Typescript knows that name is a string and anywhere I use name, either as a parameter or in an assignment or expression, Typescript will flow that string type to the next place I'm working with name.

A lot of developers when first using Typescript will add a ton of annotations to their code, only to realize later that Typescript is great at inferring type information and doesn't need us to be so explicit.