The Utils Folder 10 exercises
explainer

Introduction to the Utilities Folder

When working with TypeScript, there are three primary levels of complexity.

Application Development

The first level is Application Development. This is the level we've been concentrating on so far. Here, we mostly use the fundamental features of TypeScript: annotating types, defining function p

Loading explainer

Transcript

00:00 You can think of that as being three levels of TypeScript complexity. There's application development, which is kind of the level that we've been working towards all this time.

00:09 Often you'll just be using kind of like the main 25% of what TypeScript can do, just annotating types, making sure that your function parameters are defined, and using things like, you know, object types, array types, sometimes tuples, as const, all the things we've been talking about. Then, at the other end of the level, there's library development.

00:29 This is where you're building types for libraries. Often, if you look at something like the Redux types, the runtime code is pretty small, but the types are actually immensely large, maybe six times the size of what the actual runtime code is doing.

00:43 That's because the types are so complex, you need a lot of transformations in there, you need map types, you need a lot of the things that we've seen in the designing the types chapter. But there is a third level between them. Application development all the way over here, library development over here. But often what you'll find is in your applications, you'll have some shared code.

01:03 And that shared code is going to basically live in probably one spot in your application, or maybe in a monorepo, let's say. And then it gets shared across lots of different parts of your app, you know, group by functions, utility functions, shared business logic. And this is the utils folder.

01:20 And inside here, you are going to need some relatively complicated typescript, not as complicated as library code, but certainly more complicated than what you've seen in application development code. And so in this chapter, what we're going to be doing is talking about those different techniques that you might need, and introducing you to some of those and showing you what's possible.

01:39 We're not going to dive fully into, let's say, generics and generic functions, that kind of thing. We're just going to introduce the concepts and make sure you've got a grounding in the kind of things that they can do. And you can use the docs for the full explanations. So let's get started.