Static methods in class client
#2322
Closed
sebastianvitterso
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
|
Looks like a great idea, let's move this to an issue so it can be worked on. Always open for some contributions so if you want I can explain what is needed for this (should not be to hard). @sebastianvitterso |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Some other libraries like Kubb allow the generation of class-clients/services with static members, allowing us to change the usage:
This can be achieved by simply adding an option for
pluginClient().clientType='staticClass'(or something), which would change generated client signature as follows:export class TestService { - #client: typeof fetch + static #client: typeof fetch - async doTestAction(testId: TestActionParam["testId"], data: TestActionMutationRequest, config: Partial<RequestConfig<TestActionMutationRequest>> & { client?: typeof fetch } = {}) { + static async doTestAction(testId: TestActionParam["testId"], data: TestActionMutationRequest, config: Partial<RequestConfig<TestActionMutationRequest>> & { client?: typeof fetch } = {}) { ...And other necessary changes, like how references to
thismust be replaced byTestService. For example, replacethis.#clientwithStepService.#client(and potentially make it non-private, not sure how best-practice is for this).Beta Was this translation helpful? Give feedback.
All reactions