Learning TypeScript: Value of a Strongly Typed Projects 💪
Tags: typescript, learning, growth
Published: 2019-11-05 22:06:48

One the first things you're going to encounter working with TypeScript is this idea that it's prohibitive or it's a lot of setup. I've been there. Then I remember this quote:

> TypeScript shines not on day 1, but on on day 100, and becomes a freaking supernova on day 500. -- [Jared Palmer](https://twitter.com/jaredpalmer/status/1057115161616637952)

As you start working in a codebase you don't have a lot there. Then add some community types for the libraries you're using; that's one level of productivity, the libraries you're using are now showing where you're using their API wrongly, and that's sort of helpful on a level but we can do better.

Then you have more code and more requirements in your project and those types you're adding accrue by a magnitude. At this point your application has certain models or pieces of UI or concepts that you want to make discernible, like in a chat app you might have a type interface for the message and one for the thread of messages.

```typescript
interface IMessage {
  content: string;
  attachments: IAttachment[];
  sender: IUser;
  dateSent: Date;
}

interface IThread {
  messages: IMessage[];
  isTyping: boolean;
  pollingInterval: number;
}
```

Now let's image the `IMessage` interface changes, your code to add a message or poll for new messages is likely to be broken because of that. Because you introducted this interface and can now see where your application was using, you can see with a small change the impact of that change. That to me this is one of the key values of using strong types and it's not one you see you day one, it's one you see when you're deep into a project and adding new features.

### Strongly Typed?

You might've heard people throw around this term "strongly typed" (like I just did), a strongly typed project or a strongly typed language. When I first heard it, I wasn't quite sure what it meant. To answer that we need to define what a "weak" types are; weak types are type annotations that don't break compliation or in some way permissible where by contrast, strongly typed projects or languages fail compliation if a type error exists. Using TypeScript's ["strict mode"](https://dev.to/briwa/how-strict-is-typescript-s-strict-mode-311a) can be a method for building a strongly typed project.

Anyway, if you're feeling the pain or the tedium of migrating to TypeScript or getting start with it, trust me from experience, it pays off, especially when you get to a point where you have to make bigger refactors in your project or need to build more features, from experience you can do that with my more confidence embracing a strong types in your project.

_Wherever you are in your journey with TypeScript, sign up for my [newsletter](https://charlespeters.net/subscribe), follow me on Twitter [@charlespeters](https://twitter.com/charlespeters) or find me at [charlespeters.net](https://charlespeters.net/), I'm working on some resources to help._ 

---

## Links 📝

These are some seriously cool things I encountered while I was working the last couple of weeks.

- [**Formik 2 in Hooks**](https://github.com/jaredpalmer/formik/releases/tag/v2.0.1): Formik, like React Router or is one of those tools you just grab when you're building a project of any real size. With the latest release, you can now ditch the Render Props pattern for hooks and components and I got the rare chance to role this out on a branch in my current sprint and I couldn't be happier with how much code I got rid and how much easier it was to work with.
- [**_Effective TypeScript: 62 Specific Ways to Improve Your TypeScript_**](https://www.amazon.com/Effective-TypeScript-Specific-Ways-Improve/dp/1492053740): I heard Dan Vanderkam speak at TSConf this year and I am ridiculously excited for the giant company that delivers things quickly to my house, to quickly deliver his book to my house.


---

_Sign up for my [newsletter](https://tinyletter.com/charlespeters), follow me on Twitter [@charlespeters](https://twitter.com/charlespeters) or find me at [charlespeters.net](https://charlespeters.net/)._