Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better user-facing types #142

Open
joe-p opened this issue Jan 6, 2025 · 6 comments
Open

better user-facing types #142

joe-p opened this issue Jan 6, 2025 · 6 comments
Labels
enhancement New feature or request

Comments

@joe-p
Copy link
Contributor

joe-p commented Jan 6, 2025

Currently the types on the generated client methods are not very helpful because there are various layers of TypeScript magic going on. The types presented to the user should be very clear in terms of what the expected inputs (or outputs) of a function are.

image

The easiest way is to probably use even more TypeScript magic to expand the types at the highest level. Something like this PR for the SDK: algorand/js-algorand-sdk#528

Eventually it might be worthwhile to have the types just be defined as explicit, even if there is some repetition in the generated code.

@robdmoore
Copy link
Contributor

I added a healthy dose of Expand when making changes recently. I tested it in vs code when doing it and the intellisense seemed a lot better. Maybe tehre is still room for improvement though?

e.g. https://github.com/algorandfoundation/algokit-client-generator-ts/blob/main/examples/helloworld/client.ts#L129 and https://github.com/algorandfoundation/algokit-client-generator-ts/blob/main/examples/helloworld/client.ts#L624

@robdmoore robdmoore added the enhancement New feature or request label Jan 9, 2025
@joe-p
Copy link
Contributor Author

joe-p commented Jan 9, 2025

I think the expand needs to wrap at the higher-level types otherwise it's not actually expanding them for the user.

CleanShot 2025-01-09 at 11 12 37@2x

@robdmoore
Copy link
Contributor

From memory I found that when the intellisense came up for the args object itself it was clear and if I moved the expand to the method signature itself it was harder to read

@joe-p
Copy link
Contributor Author

joe-p commented Jan 9, 2025

Just to illustrate what Rob is talking about:

CleanShot 2025-01-09 at 12 24 33@2x

I stil think having readable args at the method level is important though. Perhaps it'll just be easier to have the generator spit out explicit types rather than using these complex typescript type definitions.

@robdmoore
Copy link
Contributor

robdmoore commented Jan 10, 2025

Here's what I see...
image
image
image

@robdmoore
Copy link
Contributor

Side-note: I started out using Expand directly, but the problem I found when using Expand was I saw some problems in trying to define variables that are the equivalent type of a function parameter, so I started using Expand in a defined type and found I still got good intellisense, but had less typing issues in defining variables for the parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants