Hacker News new | ask | show | jobs
by sirmarksalot 1236 days ago
This is technically correct, but I suspect it's pretty rare that you would choose "unknown" over a generic parameter. Even if you're writing an algorithm that doesn't care about the data type, it's still probably going to be used by application code that does care, and you'll want to support that need by passing the type through, otherwise the application will be forced to downcast.
1 comments

I often use it to infer one generic parameter:

type Output<Fn> = Fn extends ((a: unknown) => infer Out) ? Out : never;