TypeScript can help you get shit done faster

TRUE facts:

  • TypeScript is a superset of JavaScript
  • TypeScript was built with the purpose of creating tools to increase developers' productivity (Anders Hejlsberg)
  • All JavaScript code is TypeScript code — you don’t need to learn a new language
  • JavaScript with the future features available today (TypeScript implements proposals on ECMAScript Stage 3)
Optional Chaning
  • You can catch errors before running your app
Catch errors in compile-time rather than runtime
  • You can refactor your code, it’s no longer read-only
F2 (rename with the help of TypeScript)
  • You can get autocompletion for nearly every package out there and for your own code
React + Material UI
Your own stuff
  • Dial it all the way to zero or all dial it as high as you want (Anders Hejlsberg)
not strict
  • Typescript doesn’t have to be explicit — you don’t have to add types to every single variable, TypeScript can infer types and have it automatically available for you
  • TypeScript is very flexible with everything; you can use it and benefit a lot from it without making it a nuisance


  • have classes — JavaScript has classes, all that TypeScript does is to translate JavaScript code into today’s JavaScript code
  • forcers you to use a pattern (like OO) — you can choose which patterns you want to use, closures, classes, or anything in between
  • compare to CoffeeScript or similar things — comparing TypeScript to these things is like comparing apples to carburetors (Scott Hanselmann); TypeScript is not a syntax sugar for JavaScript, it is JavaScript, meaning the syntax is the same

Real World Examples?

TypeScript is saying that the “if” condition is never ever going to be true, because the types `array` and `string` have no overlap.
strict can be a pain in real world code; in this case if text is null the function will return `null as string` which is not assignable to `boolean`
strict off; works exactly as intended

How do I keep my code clean without being strict?

  • “noUnusedLocals”: true,
  • “noUnusedParameters”: true,

But also…

  • Meaningful names — choose good names for your variables and functions so that you know what they are/do by just reading their names
  • Avoid mental mapping — write code that you can understand by just reading as a book, if you have to think/do calculations in your head, then your code is not as clean as it could be
  • Avoid disinformation — make sure you don’t put name on things that says that they do something they don’t
  • Make meaningful distinction — choose specific names to avoid ambiguity
  • Use searchable names — make sure you don’t have typos and use names that can be found a later time when you need to find things
  • Be consistent — use same naming pattern for things that do the same thing
  • Comments — don’t write comments unless there’s some extremely specific information that needs to be conveyed, or some intent, or some warnings about consequences. Otherwise, your code should be written in a way that you can read as if it was a book. Or if you’re writing some regexes

Find balance

  • don’t write shit code that causes a lot of bugs or makes it impossible to develop new features
  • don’t overengineer
  • don’t make things more complicated than they need to be right now (YAGNI & DTSTTCPW engineering & features) / don’t worry about the beauty and elegance of your code
  • don’t focus on trends
  • don’t design & develop features that don’t work
  • don’t waste time discussing a bike shed


Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Merging JavaScript Objects

How to publish a static web using Surge?

Creating Facebook Chat Head Bubbles in React Native

Animated Collapsible Header Using React Native Reanimated 2

Simple Snake game in HTML and JavaScript

An Introduction to Angular

Basic and Interesting method of Array in JavaScript.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bruno Leonardo Michels

Bruno Leonardo Michels

More from Medium

You might not need all those design patterns in TypeScript

TypeScript Utility: keyof nested object

‘as const’ in TypeScript

How to enforce TypeScript types in the runtime environment