Hacker News new | ask | show | jobs
by Waterluvian 1157 days ago
While no actual Turing machine’s tape is infinitely long, I found issues in TypeScript with how finite generics are.

You have to define every possible count of generic arguments if you want to preserve their types. And if you go above that count your type system degrades. I think there’s also a maximum of 7 or so before it doesn’t work. Beyond that and the generic type widens.

For example, Lodash enumerating types for 2 to 7 generic items per function: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0452...

Admittedly I don’t understand the problem space well. I’ve just seen it happen to me and in others’ code. It might not actually be an issue, or is already fixed.

1 comments

This was fixed in Typescript 4.0, with the introduction of variadic tuples: https://www.typescriptlang.org/docs/handbook/release-notes/t...
Oh awesome! Thanks for sharing.