A Simple Argument For Typescript

Nick Scialli (he/him) - Apr 23 '20 - - Dev Community

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?

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player