Remix.run Logo
solidsnack9000 7 months 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.

throwitaway1123 7 months ago | parent | next [-]

TypeScript 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.h...

[2] https://www.typescriptlang.org/docs/handbook/utility-types.h...

solidsnack9000 7 months ago | parent [-]

Yeah, now that you mention it, I remember using it a lot when I worked more in that language.

7 months ago | parent | prev | next [-]
[deleted]
1_1xdev1 7 months ago | parent | prev [-]

Like `ParamSpec`?

maleldil 7 months ago | parent [-]

ParamSpec 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.