fix(runtime): no-arg action commands fail to type-check in consumers#8
Merged
Conversation
…ands)
0.1.9 generates `command(z.void(), async () => handlePostCommand(path))` for endpoints
with no path params and no request body — a 1-argument call. But the handler's `input`
was required, so the *generated* file failed to type-check in the consumer ('Expected 2
arguments, but got 1'). Make `input` optional (runtime already tolerates undefined).
No regen needed to adopt — existing 0.1.9 output type-checks once the handler is optional.
Verified against a real consumer: the errors go from N to 0.
Adds an integration test that generates remote functions from a fixture and compiles them (tsc) against the real createRemoteHandlers signatures + a SvelteKit $app/server stub. This catches consumer-facing type breaks in generated code — e.g. the no-arg z.void() command calling a 2-arg handler — which previously slipped through because the generator's string output and the handlers were only tested separately. New edge-cases fixture covers every shape (incl. the no-path/no-body z.void() case that none of the real fixtures exercise). Verified: reverting the handler fix makes this test fail with the exact 'Expected 2 arguments' error.
Owner
Author
|
Addressed the note in this PR ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #5. 0.1.9's generator emits a no-argument command for endpoints with no path params and no request body:
But
handlePostCommand(path, input)declaredinputas required, so the generated file itself failed to type-check in the consuming app:(It worked at runtime —
inputwas justundefined— so only type-check / CI was affected.)Fix
Make
inputoptional onhandlePostCommand/handlePatchCommand/handlePutCommand.buildRequestOptions(undefined)already yields no params and no body, so behavior is unchanged. No regeneration needed to adopt — existing 0.1.9 output type-checks as soon as the handler is optional.Verified
handlePostCommand('/x')(1 arg) →client.POST('/x', {}).svelte-check— the "Expected 2 arguments" errors went from N to 0.Note
This slipped through because the library doesn't type-check its own generated output — only the generator's string output and the runtime handlers, separately. Worth a follow-up: compile a generated fixture in CI so consumer-facing type breaks are caught here. No version bump.