kubb-labs / kubb

OpenAPI to TypeScript, React-Query, Zod, Zodios, Faker.js, MSW and Axios.
https://kubb.dev
MIT License
568 stars 40 forks source link

Fix/object type #1055

Closed dgarciamuria closed 3 weeks ago

dgarciamuria commented 3 weeks ago

Issue

If you have typescript-eslint enabled in your project, you might run into a situation where you get some errors related about the use of {} as type after generating the code.

Solution

This adds a check to see if nodes.length is 0, meaning the node doesnt have any children and thus should be treated as an object instead of creating a new literal node...probably the original condition was wrong since ![] is a falsy value, but decided to keep it as it was to avoid any potential regression

changeset-bot[bot] commented 3 weeks ago

🦋 Changeset detected

Latest commit: 426cc2a4f1a879efea3dd3c6381dc2797a25e178

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages | Name | Type | | ---------------------------- | ----- | | @kubb/swagger-ts | Patch | | @kubb/swagger-client | Patch | | @kubb/swagger-faker | Patch | | @kubb/swagger-msw | Patch | | @kubb/swagger-swr | Patch | | @kubb/swagger-tanstack-query | Patch | | @kubb/swagger-zod | Patch | | @kubb/swagger-zodios | Patch | | @kubb/cli | Patch | | @kubb/config-biome | Patch | | @kubb/config-ts | Patch | | @kubb/config-tsup | Patch | | @kubb/core | Patch | | @kubb/fs | Patch | | @kubb/oas | Patch | | @kubb/parser-ts | Patch | | @kubb/plugin-oas | Patch | | @kubb/plugin-redoc | Patch | | @kubb/react | Patch | | @kubb/swagger | Patch | | @kubb/types | Patch | | kubb | Patch | | unplugin-kubb | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

stijnvanhulle commented 3 weeks ago

@all-contributors add @dgarciamuria for code

allcontributors[bot] commented 3 weeks ago

@stijnvanhulle

@dgarciamuria already contributed before to code

dgarciamuria commented 3 weeks ago

updated snapshot