Skip to content

Commit d440b4b

Browse files
justin808claude
andauthored
Fix TypeScript error in processPromise return type (#2204)
## Summary - Fixed TypeScript compilation error in `serverRenderReactComponent.ts` that was blocking the release script - The error occurred because TypeScript couldn't narrow the type properly after the `isValidElement` check in the `.then()` callback - Added explicit type assertion to `FinalHtmlResult` since after the `isValidElement` check, the remaining types (`string` and `ServerRenderHashRenderedHtml`) are all valid `FinalHtmlResult` types ## Test plan - [x] TypeScript type-check passes (`pnpm run type-check`) - [x] Build completes successfully (`pnpm run build`) - [x] ESLint passes (`pnpm run lint`) 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved type safety for server-side rendering operations to ensure more robust handling of promise resolutions. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5d5900c commit d440b4b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/react-on-rails/src/serverRenderReactComponent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { renderToString } from './ReactDOMServer.cts';
99
import { createResultObject, convertToError, validateComponent } from './serverRenderUtils.ts';
1010
import type {
1111
CreateReactOutputResult,
12+
FinalHtmlResult,
1213
RenderParams,
1314
RenderResult,
1415
RenderState,
@@ -71,7 +72,8 @@ function processPromise(
7172
if (isValidElement(promiseResult)) {
7273
return processReactElement(promiseResult);
7374
}
74-
return promiseResult;
75+
// promiseResult is string | ServerRenderHashRenderedHtml (both are FinalHtmlResult)
76+
return promiseResult as FinalHtmlResult;
7577
});
7678
}
7779

0 commit comments

Comments
 (0)