Extreme Explorations of TypeScript's Type System

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • Appwrite - The open-source backend cloud platform
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • Revelo Payroll - Free Global Payroll designed for tech teams
  • Sonar - Write Clean JavaScript Code. Always.
  • pothos

    Pothos GraphQL is library for creating GraphQL schemas in typescript using a strongly typed code first approach

    If you're a GraphQL developer, Pothos is the best example - all your user-defined types just fits in it like a glove 99% of the time. It definitely makes the most use of TS generics.

    https://pothos-graphql.dev/

    (I'm a bit sleepy, so this is the main one I can think of at the moment that I really enjoy using.)

  • type-fest

    A collection of essential TypeScript types

    > TypeScript's type annotations are really a DSL embedded into JavaScript. And they can, and, depending on the problem at hand, should be treated as such.

    I think this is the key. If treated as you describe, meaning the advanced types are well-written, well-documented, and well unit-tested as if they are "true" code, then using them shouldn't be too much of an issue.

    However, I think people often just assume that the types aren't "real" code and thus the normal concepts of good software engineering don't apply and type monstrosities which nobody can understand result.

    Imagine if this code[0] wasn't well documented, fairly clearly written, and also tested. It would definitely be a liability in a codebase.

    In addition, the rules of how advanced TypeScript concepts work can be quite nuanced and not always extremely well defined, so you can end up in situations where nobody even _really_ understands why some crazy type works.

    [0]: https://github.com/sindresorhus/type-fest/blob/2f418dbbb6182...

  • Appwrite

    Appwrite - The open-source backend cloud platform. The open-source backend cloud platform for developing Web, Mobile, and Flutter applications. You can set up your backend faster with real-time APIs for authentication, databases, file storage, cloud functions, and much more!

  • redux-toolkit

    The official, opinionated, batteries-included toolset for efficient Redux development

    We do a _lot_ of this in the Redux library repos (examples: [0] [1] [2] ). We have some incredibly complicated types in our libraries, and we have a bunch of type tests to confirm expected behavior.

    Generally, these can just be some TS files that get compiled with `tsc`, but it helps to have a bunch of type-level assertions about expected types.

    I actually recently gave a talk on "Lessons Learned Maintaining TS Libraries" [3], and had a couple slides covering the value of type tests and some techniques.

    [0] Redux Toolkit's `createSlice`: https://github.com/reduxjs/redux-toolkit/blob/9e24958e6146cd...

    [1] Reselect's `createSelector`: https://github.com/reduxjs/reselect/blob/f53eb41d76da0ea5897...

    [2] React-Redux's `connect`: https://github.com/reduxjs/react-redux/blob/720f0ba79236cdc3...

    [3] https://blog.isquaredsoftware.com/2022/05/presentations-ts-l...

  • reselect

    Selector library for Redux

    We do a _lot_ of this in the Redux library repos (examples: [0] [1] [2] ). We have some incredibly complicated types in our libraries, and we have a bunch of type tests to confirm expected behavior.

    Generally, these can just be some TS files that get compiled with `tsc`, but it helps to have a bunch of type-level assertions about expected types.

    I actually recently gave a talk on "Lessons Learned Maintaining TS Libraries" [3], and had a couple slides covering the value of type tests and some techniques.

    [0] Redux Toolkit's `createSlice`: https://github.com/reduxjs/redux-toolkit/blob/9e24958e6146cd...

    [1] Reselect's `createSelector`: https://github.com/reduxjs/reselect/blob/f53eb41d76da0ea5897...

    [2] React-Redux's `connect`: https://github.com/reduxjs/react-redux/blob/720f0ba79236cdc3...

    [3] https://blog.isquaredsoftware.com/2022/05/presentations-ts-l...

  • react-redux

    Official React bindings for Redux

    We do a _lot_ of this in the Redux library repos (examples: [0] [1] [2] ). We have some incredibly complicated types in our libraries, and we have a bunch of type tests to confirm expected behavior.

    Generally, these can just be some TS files that get compiled with `tsc`, but it helps to have a bunch of type-level assertions about expected types.

    I actually recently gave a talk on "Lessons Learned Maintaining TS Libraries" [3], and had a couple slides covering the value of type tests and some techniques.

    [0] Redux Toolkit's `createSlice`: https://github.com/reduxjs/redux-toolkit/blob/9e24958e6146cd...

    [1] Reselect's `createSelector`: https://github.com/reduxjs/reselect/blob/f53eb41d76da0ea5897...

    [2] React-Redux's `connect`: https://github.com/reduxjs/react-redux/blob/720f0ba79236cdc3...

    [3] https://blog.isquaredsoftware.com/2022/05/presentations-ts-l...

  • ts-regexp

    Type-Level Regular Expressions matching with TypeScript

  • ts-lambda-calc

    Type-Level Lambda Calculus interpreter with TypeScript

  • InfluxDB

    Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.

  • typefuck

    Type-level Brainfuck interpreter in TypeScript

  • TSpell

    Abusing the TypeScript type checker as a spell checker because I just can't help myself.

  • typeshaman

    Experiments with using advanced typescript types for GraphQL, SQL etc.

    https://github.com/pj/typeshaman/blob/main/packages/graphql/...

    Documentation is incomplete, unfortunately I had to get a job. I started working on encoding all of SQL as well.

  • get-optional

    Typesafe utility functions for getting a nested optional property. For TypeScript and Flow.

    My solution to this was to run tsc from Jest tests and do snapshot tests for the error messages

    https://github.com/noppa/get-optional/tree/master/tests/typi...

  • remark-typescript-tools

    Hmm. While it may not be the immediate answer to your question, my Redux teammate Lenz Weber ( @phryneas ) wrote a Remark plugin that parses TS codeblocks out of Markdown and actually runs them through the TS compiler. As part of that I know he generates a bunch of "virtual files", including some parsing that lets you add an extra section of the codeblock representing another file to be compiled along with the actual example. The source for that may at least help give you some examples of how to use TS programmatically:

    https://github.com/phryneas/remark-typescript-tools

  • tabdb

    Using browser tabs as a database like only a maniac would

  • Cypress

    Fast, easy and reliable testing for anything that runs in a browser.

  • eslint-plugin-expect-type

    ESLint plugin with ^? Twoslash, , and type assertions. 🧩

  • Onboard AI

    Learn any GitHub repo in 59 seconds. Onboard AI learns any GitHub repo in minutes and lets you chat with it to locate functionality, understand different parts, and generate new code. Use it for free at www.getonboard.dev.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts