3 ms·
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 d
by sirmarksalot 4y 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.
- thoughtspile 4y agoI often use it to infer one generic parameter: type Output<Fn> = Fn extends ((a: unknown) => infer Out) ? Out : never;