Skip to content

Remove undefined from additionalProperties union #1799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2024

Conversation

drwpow
Copy link
Contributor

@drwpow drwpow commented Aug 2, 2024

Changes

Fixes #1732, #1737, and other related issues mentioning this behavior. Removes the | undefined from the additionalProperties union that is a behavior change from 6.x.

How to Review

  • Tests updated; tests should pass (fortunately, though this is a far-reaching change, this is extremely well-tested!

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

@drwpow drwpow requested a review from a team as a code owner August 2, 2024 02:46
Copy link

changeset-bot bot commented Aug 2, 2024

🦋 Changeset detected

Latest commit: 4e0f0cf

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

This PR includes changesets to release 1 package
Name Type
openapi-typescript Minor

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

@drwpow drwpow changed the title Remove undefined from additionalProperties Remove undefined from additionalProperties union Aug 2, 2024
@drwpow drwpow force-pushed the addl-properties-no-undef branch from ef03c56 to 104bd62 Compare August 2, 2024 02:48
Copy link

cloudflare-workers-and-pages bot commented Aug 2, 2024

Deploying openapi-ts with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4e0f0cf
Status: ✅  Deploy successful!
Preview URL: https://7998dd1d.openapi-ts.pages.dev
Branch Preview URL: https://addl-properties-no-undef.openapi-ts.pages.dev

View logs

@drwpow drwpow force-pushed the addl-properties-no-undef branch 2 times, most recently from 817a603 to ed1dcbf Compare August 2, 2024 03:59
@@ -46,7 +54,8 @@ describe("transformSchemaObject > object", () => {
},
want: `{
property?: boolean;
[key: string]: string | undefined;
} & {
[key: string]: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: this intersection seems a little awkward, but is necessary for TypeScript to work properly in most cases (here, you’d get some error like “property string not assignable to type boolean | undefined”).

@drwpow drwpow force-pushed the addl-properties-no-undef branch 2 times, most recently from ec58bc9 to 747f69c Compare August 2, 2024 04:03
@drwpow drwpow force-pushed the addl-properties-no-undef branch from 747f69c to 4e0f0cf Compare August 2, 2024 04:05
@drwpow drwpow merged commit 9939b76 into main Aug 2, 2024
9 checks passed
@drwpow drwpow deleted the addl-properties-no-undef branch August 2, 2024 04:07
@github-actions github-actions bot mentioned this pull request Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

str:str dictionary generates str:str|undefined dictionary in v7.0.0
1 participant