DEV Community

Mikhail Karan
Mikhail Karan

Posted on • Originally published at

Do You Need to Learn TypeScript in 2023?

What is HTML All The Things?

HTML All The Things is a web development podcast and discord community which was started by Matt and Mike, developers based in Ontario, Canada.

The podcast speaks to web development topics as well as running a small business, self-employment and time management. You can join them for both their successes and their struggles as they try to manage expanding their Web Development business without stretching themselves too thin.

Learn Web Development with Scrimba

We're super excited to partner with Scrimba to give you a 10% off discount on their monthly and yearly course subscriptions!

We've been recommending Scrimba as a learning platform for over a year. Their advanced course platform allows you to code alonside the instructor right in teh browser!

10% off Scrimba

What's This One About?

On top of the growing collection of "must-know" tools in a web developer's arsenal is the famous (or maybe infamous?) TypeScript - a high-level programming language that adds static typing with optional type annotations to JavaScript. Developed by Microsoft, TypeScript can improve the developer experience by allowing the data that is passed around the code to be typed to something specific (ie Boolean), with TypeScript ready to throw an error if the types don't match appropriately through the program. In this episode, Matt and Mike discuss TypeScript at length discussing whether you need to learn TypeScript and how to learn it whether you're a beginner, or veteran coder.

Show Notes

What is TypeScript?

  • A way to add static types, classes, and interfaces to JavaScript
  • Catch code errors at compile time
  • Upgrades your tooling to allow for auto-complete and easy refactorablity

TypeScript Basics

  • Static Typing
    • JavaScript uses dynamic typing where a variable can be set to any type. A string, number boolean, function, etc.
    • TypeScript adds the ability to set what variable should be set to. Example
      • Let numA: number
      • Let isShowing: boolean
    • You can also have variables of multiple types using an intersection
      • String | undefined
    • Any is used when you don’t know what the type will be. Use these never
  • Interfaces and Classes
    • Both are object-oriented principles
    • Interfaces are good for creating shapes for your objects that can be merged/extended
      • Interface Person {firstName: string, lastName: string}
      • Interface athlete inherits Person { height: number, sport: string}
    • Classes can also be used in a similar way to interfaces but with the added functionality of creating constructors and methods.
  • Generics
    • Reusable components that can work over a variety of types while maintaining type safety.
    • These types/functions can be used in a variety of ways where defining static types doesn’t make sense
      • Creating a function that will be accepting multiple different types and return different types
      • Example a function using a generic that returns the first element of an array. Could work with any element and return it in a type-safe way as when you instantiate the array and use the function the type can be inferred from the array you created
  • Type Inference
    • A lot of times in TypeScript you might not even have to statically declare or type a variable because it can infer type from when you instantiate it.
      • Ex. let myName = “mike”
        • myName will be inferred as a String
  • TypeScript Compiler
    • Since TypeScript is not understood by the browser we need to use the tsc, Typescript Compiler. It will continually run while you’re developing to check for code/type errors. The compiler can be configured with a tsconfig.json file

Do you need to know TypeScript?

  • TypeScript has started to become a standard in the web development space
  • With that most job postings I’ve recently checked in my area have listed it as part of the required or recommended skills
  • If you’re looking for a job it might be a good idea to dive into TypeScript, maybe take a short course from Matt Pocock and try to convert one of your existing JavaScript projects to TypeScript
  • You SHOULD NOT try to learn all of the ins and outs of TypeScript before applying for a job.
    • A good handle on Static Typing, Generics, and Type Inference should be enough to jump in.
    • You’ll learn more when you start working on a large TypeScript project than by reading/watching tutorials. Employers usually know this*
  • Do you need TypeScript for your side projects?
    • It depends on what your goals are, if you’re the only one working on it and it is just a way for you to create your side hustle, you probably don't need TypeScript
    • If your goal is to use the project as a portfolio piece and to get a job, then TypeScript is probably a good idea, regardless of the size of the project

Thank you!

If you're enjoying the podcast consider giving us a review on Apple Podcasts or checking out our Patreon to get a shoutout on the podcast.

Support us on Patreon

You can find us on all the podcast platforms out there as well as

Instagram (@htmlallthethings)
Twitter (@htmleverything)

Top comments (0)