A look at how both statically and dynamically typed languages have pros and cons and how we should identify the benefits and choose languages that provide the best of both worlds.

Image for post
Image for post
Is this what duck typing leads too? Source

I coach developers in both statically and dynamically typed languages. Several of the courses I teach can be delivered equally well in JavaScript or TypeScript. Python and Java courses are both very popular.

Internally as well we have good debates over the relative merits of dynamic vs static languages. My colleague Ryan Adams made great points about choosing good software development practices over relying on static typing and showed the elegance of something like Python over Java, in his piece Static types won’t save us from bad code. …

In this article I’ll take a look at some new features in TypeScript 4.1 — namely Template Literal Types, Key Remapping and Recursive Conditional Types. At the end I’ll show some crazy examples of using these features to do a bit of meta-programming.

Image for post
Image for post

New Features in TypeScript 4.1

I’ve always loved TypeScript and the language just keeps getting better with each evolution. 4.1 has lots of interesting new features. Here I’m going to look at:

  • Template Literal Types
  • Key Remapping in Mapped Types
  • Recursive Conditional Types

Template Literal Types

TypeScript has supported string literals types since 1.8.

type Beatles = "John" | "Paul" | "George" | "Ringo"

These are extremely powerful when we want to bring safety to stringly typed API’s. Literal types were later extended to support numeric, boolean and enum literals as well. …

About

Eamonn Boyle

15 years working as a developer. For the last 4 years I've been working as a full time trainer and coach, authoring and delivering courses on a range of topics.

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