3 September 2022 - 2 min read

@types Considered Harmful

and I think we as a TypeScript community should actively discourage their usage.

Let me start by telling you a very short story:

Today I fixed a bug. The bug was caused by passing the wrong prop to a React Native component. I was passing autoCompleteType, the component wanted autoComplete.

But don't you use TypeScript? Wouldn't this be a type error?

Absololutely, but on this occasion the types were distributed via a seperate channel - @types/react-native - and I, dear reader, forgot to upgrade the types at the same time as I upgrades the react-native package.

In an ideal world this example would convince you that any JS library worth taking remotely seriously should distribute their types in the same package as the code they relate to. I've worked a bit with Deno and I can tell you this really is an amazing world to live in. But to live in that world, we must kill all @types/ packages.

If you're still not convinced, here are some other reasons:

In defence of @types

DefinitelyTyped, the folks that run it, and the folks that have contributed to it are to be appluaded. It's hard to see TypeScript spreading so far and wide without it, and for that - in the absense of dollars - I have to offer my thanks.

I just think we've outgrown them.


Discuss this post in the GitHub discussion or on Twitter.

Tom Sherman

Hey 👋 I'm Tom, a Software Engineer from the UK.

I'm currently a Software Engineer at OVO Energy. I'm super into the web, functional programming, and strong type systems.

You can most easily contact me on Mastodon but I'm also on Twitter, LinkedIn, and GitHub.