Titian Cernicova Dragomir 💙💛 Profile picture
Typescript enthusiast (ask me about TS). I work at Bloomberg in JavaScript Infrastructure & Tooling . Opinions are my own.
Mar 9, 2022 • 6 tweets • 3 min read
As a follow on to yesterday’s post (inspired by @dagda1's question), what is the difference between using any[], unknown[] or never[] as constraints to the function rest parameter in #TypeScript ?

1/6🧵

The answer is that if you use a type parameter for the args, there isn’t much difference. You can’t call the function with anything that isn’t typed as A, since you can’t assign a concrete type to a type parameter.
2/6🧵
typescriptlang.org/play?#code/GYV…
Mar 8, 2022 • 5 tweets • 2 min read
A classic problem in Typescript is warping a function in another function. Maybe also changing the parameter in some way in the process. Such as in this questions stackoverflow.com/a/71351477/125… or this one stackoverflow.com/a/71371775/125…
1/5🧵 The first problem is usually how we choose our type parameters. There are two common approaches.
2/5🧵