A Simple Argument For Typescript

nas5w

Nick Scialli (he/him)

Posted on April 23, 2020

A Simple Argument For Typescript

My favorite argument for typescript is that, in many cases, it doesn't even let you do the wrong thing.

Let me show you what I mean.

In this example, I forgot the name of the complete property of the todo object. Typescript won't even compile my code and my editor shows linting errors:

type Todo = {
  name: string;
  complete: boolean;
}

const newTodo: Todo = {
  name: "Walk the dog",
  finished: false
}
Enter fullscreen mode Exit fullscreen mode

And the linting errors showing my type is wrong:

linting error

Any javascripters intrigued?

💖 💪 🙅 🚩
nas5w
Nick Scialli (he/him)

Posted on April 23, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related