AD
Episode
249
Interview
Web News

Do You Need To Learn TypeScript in 2023?

Recorded:
May 16, 2023
Released:
May 24, 2023
Episode Number:
249

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.

Listen

Also available on...
...and many more, check your podcast app!

Who’s in This Episode?

Show Notes

Show Notes

What is TypeScript?

  • Offers a way to add static types, classes, and interfaces to JavaScript
  • Catches code errors at compile time
  • Upgrades your tooling to allow for auto-complete and easy refactorability

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 (ie Boolean)
    - Can also have variables of multiple types using an intersection (ie String | undefined)
    - Any is used when you don’t know what the type will be (ideally don't use these ever)
  • Interfaces and Classes
    - Both are object-oriented principles
    - Interfaces are good for creating shapes for your objects that can be merged/extended
    - 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
  • Type Inference
    - 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 learn 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
  • 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

Alternatives to TypeScript

  • JSDoc
  • CoffeeScript
  • Flow