Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

unknown is not equivalent to any as a type constraint: doesn't work.

https://www.totaltypescript.com/any-considered-harmful#type-...



The widest possible function type is `(...args: never) => unknown`. This is because parameters are contravariant, and `never` is the bottom type. Using that type works in the author's example[0].

I've got an issue open about TypeScript's provided `ReturnType` type which is somewhat related to this[1].

[0]: https://tsplay.dev/Wy0Ogm

[1]: https://github.com/microsoft/TypeScript/issues/55667




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: