Skip to content

fix(codegen): narrow generateEndpoints return type#5237

Open
aryaemami59 wants to merge 1 commit intoreduxjs:masterfrom
aryaemami59:fix/codegen/generateEndpoints-return-type
Open

fix(codegen): narrow generateEndpoints return type#5237
aryaemami59 wants to merge 1 commit intoreduxjs:masterfrom
aryaemami59:fix/codegen/generateEndpoints-return-type

Conversation

@aryaemami59
Copy link
Member

Summary

This eliminates the need for manual type assertions like await generateEndpoints(...) as string in consumer code.

@aryaemami59 aryaemami59 added this to the 3.0 milestone Feb 25, 2026
@aryaemami59 aryaemami59 self-assigned this Feb 25, 2026
@aryaemami59 aryaemami59 added the RTKQ-Codegen Issues related to the @rtk-query/codegen-openapi package. label Feb 25, 2026
@codesandbox
Copy link

codesandbox bot commented Feb 25, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify
Copy link

netlify bot commented Feb 25, 2026

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit bcc6556
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/69b2589031dfee000871ea94
😎 Deploy Preview https://deploy-preview-5237--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 25, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bcc6556:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a follow-up change in @rtk-query/codegen-openapi to improve the TypeScript ergonomics of generateEndpoints by narrowing its return type based on whether outputFile is provided, eliminating the need for consumer-side type assertions.

Changes:

  • Add overload signatures for generateEndpoints to return Promise<string> when outputFile is omitted, and Promise<void> when outputFile is provided.
  • Add runtime + type-level tests validating the new narrowing behavior (including *.test-d.ts typecheck coverage).
  • Update Vitest-related dependencies / configuration to support the added typecheck tests.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
yarn.lock Updates Vitest (and related deps) used by the repo/test setup.
packages/rtk-query-codegen-openapi/vitest.config.mts Adjusts Vitest config (including enabling typecheck) to support the new type tests.
packages/rtk-query-codegen-openapi/test/generateEndpoints.test.ts Adds runtime assertions for returned value shape with/without outputFile.
packages/rtk-query-codegen-openapi/test/generateEndpoints.test-d.ts Adds type-level tests asserting overload-based return type narrowing.
packages/rtk-query-codegen-openapi/src/index.ts Introduces the overload signatures for generateEndpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aryaemami59 aryaemami59 marked this pull request as ready for review February 25, 2026 22:32
@aryaemami59 aryaemami59 force-pushed the fix/codegen/generateEndpoints-return-type branch from 4eb1aaa to 6b396d3 Compare March 7, 2026 15:05
Co-authored-by: Issy Szemeti <48881813+issy@users.noreply.github.com>
@aryaemami59 aryaemami59 force-pushed the fix/codegen/generateEndpoints-return-type branch from 6b396d3 to bcc6556 Compare March 12, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RTKQ-Codegen Issues related to the @rtk-query/codegen-openapi package.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants