4 ms·
It seems like the author is looking for the ability to specify types as `typeof <function>:arguments` and `typeof <function>:return`. I can see how this could m
by solidsnack9000 2y ago
It seems like the author is looking for the ability to specify types as `typeof <function>:arguments` and `typeof <function>:return`. I can see how this could make prototyping easier. It is also helpful for cases (not uncommon in Python) where you're just proxying another function.
- deleted 2y ago[deleted]
- throwitaway1123 2y agoTypeScript has the equivalent of what you're describing via the `Parameters` and `ReturnType` utility types [1][2], and I've found these types indispensable. So you can do the following: type R = ReturnType<typeof someFunction> type P = Parameters<typeof someFunction> [1] https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype https://www.typescriptlang.org/docs/handbook/utility-types.h... [2] https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypetype https://www.typescriptlang.org/docs/handbook/utility-types.h...
- solidsnack9000 2y agoYeah, now that you mention it, I remember using it a lot when I worked more in that language.
- 1_1xdev1 2y agoLike `ParamSpec`?
- maleldil 2y agoParamSpec doesn't have the same objective as what they're saying. The sibling comment shows how you can get the proper types in TypeScript and use them as types for other functions. On the other hand, ParamSpec is a hack to properly forward function argument types to decorators.