conform
conform copied to clipboard
Remix single fetch: returning submission.reply() with action results in type never.
Describe the bug and the expected behavior
https://github.com/remix-run/remix/issues/9374
Conform version
v1.1.3
Steps to Reproduce the Bug or Issue
https://stackblitz.com/~/github.com/coji/conform-on-remix-single-fetch
What browsers are you seeing the problem on?
Chrome
Screenshots or Videos
Additional context
I have also raised it as a remix issue. I think it may be a type definition problem on the remix side. https://github.com/remix-run/remix/issues/9374
I've received feedback from several users about an issue with SubmissionResult's prop Result<string, unknown>. The unknown type is problematic because it introduces uncertainty about serializability by turbo-stream, which could lead to runtime errors. https://github.com/remix-run/remix/issues/9374#issuecomment-2096739839
To address this, it's recommended to replace unknown with a more specific type that turbo-stream can reliably serialize. This will improve type safety and prevent potential issues. However, I'm not quite sure how to best implement this change while maintaining compatibility and avoiding any unintended consequences. I would greatly appreciate your guidance on the most appropriate way to refactor the code to resolve this problem.
I've updated to remix v2.9.2 and the type error is gone,
However, the newly introduced defineAction / defineLoader still seems to cause type errors due to Result<string, unknown>
.
https://github.com/remix-run/remix/issues/9374#issuecomment-2106128088
I'm encountering the type error with defineAction
as well. I worked around it for now by omitting the initialValue
prop since that's the one with the Record<string, unknown>
type. Would definitely love an official fix though 🙂
@coji FYI this specific error is caused by a typo. You're using actionData.lastResult
while your action returns lastRusult
Has anyone managed to get conform submission.reply() working with the new remix singlefetch and the new unstable_data to return raw data accompanied with a status code or custom response headers. I am getting
Type 'SubmissionResult<string[]> | DataWithResponseInit<SubmissionResult<string[]>> | undefined' is not assignable to type 'SubmissionResult<string[]> | null | undefined'. Type 'DataWithResponseInit<SubmissionResult<string[]>>' has no properties in common with type 'SubmissionResult<string[]>'.ts(2322)
when trying to assign lastResult to the useForm hook?