Not sure whether there exist other solutions, but what you suggest here is more or less the same as the solution provided by @Mason in this older thread:
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Creating the instance of a function type | 13 | 444 | November 7, 2024 | |
| How to get a function instance from a function type? | 3 | 752 | April 17, 2022 | |
| Extract function from function type | 13 | 674 | November 22, 2022 | |
| Is there a way to get f from typeof(f)? | 17 | 4268 | December 29, 2018 | |
| How to get anonymous function from its type? | 3 | 560 | April 26, 2021 |