I'm trying to construct a dependency resolution function (for a hobby project of mine, thylang.com), and I'm hitting a wall with implementing strong type safety for it.
I want to be able to provide an array of functions that all just get run but any given function in the array can obtain a dependency provided from any other function. I have no issues with implementing the runtime algorithm for this approach, but I can't come up with a good way to type it.
I'm coming to the conclusion that this problem is unsolvable for TypeScript, but I'm open to next-level black-magic solutions that defy TypeScript limits (e.g. https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540) or to alternative solutions which mostly meet the requirements of my system while adding additional usage burden.
(Playground link in next message)