Skip to content

fix(codegen): narrow generateEndpoints return type#5237

Merged
aryaemami59 merged 1 commit into
reduxjs:masterfrom
aryaemami59:fix/codegen/generateEndpoints-return-type
May 5, 2026
Merged

fix(codegen): narrow generateEndpoints return type#5237
aryaemami59 merged 1 commit into
reduxjs:masterfrom
aryaemami59:fix/codegen/generateEndpoints-return-type

Conversation

@aryaemami59
Copy link
Copy Markdown
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
Copy Markdown

codesandbox Bot commented Feb 25, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 25, 2026

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

Name Link
🔨 Latest commit ac807c3
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/69f93a0b97c5ca0008e8842c
😎 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.
🤖 Make changes Run an agent on this branch

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

@codesandbox-ci
Copy link
Copy Markdown

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 ac807c3:

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

Copy link
Copy Markdown

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.

Comment thread packages/rtk-query-codegen-openapi/src/index.ts
@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 2 times, most recently from 6b396d3 to bcc6556 Compare March 12, 2026 06:09
@aryaemami59 aryaemami59 force-pushed the fix/codegen/generateEndpoints-return-type branch from bcc6556 to 537a56b Compare March 17, 2026 17:58
@aryaemami59 aryaemami59 added the TypeScript Issues related to TypeScript. label Mar 18, 2026
@aryaemami59 aryaemami59 force-pushed the fix/codegen/generateEndpoints-return-type branch 2 times, most recently from 422abe6 to ffc50d6 Compare April 5, 2026 02:02
@aryaemami59 aryaemami59 force-pushed the fix/codegen/generateEndpoints-return-type branch from ffc50d6 to 5f07afe Compare April 22, 2026 17:03
Copy link
Copy Markdown

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


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

Co-authored-by: Issy Szemeti <48881813+issy@users.noreply.github.com>
@aryaemami59 aryaemami59 force-pushed the fix/codegen/generateEndpoints-return-type branch from 5f07afe to ac807c3 Compare May 5, 2026 00:30
@aryaemami59 aryaemami59 merged commit de2d55e into reduxjs:master May 5, 2026
18 checks passed
@aryaemami59 aryaemami59 deleted the fix/codegen/generateEndpoints-return-type branch May 5, 2026 00:43
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. TypeScript Issues related to TypeScript.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants