Skip to content
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

NonNullable bloating the typings file #33

Closed
3 tasks done
kostia1st opened this issue May 30, 2024 · 4 comments · Fixed by #34
Closed
3 tasks done

NonNullable bloating the typings file #33

kostia1st opened this issue May 30, 2024 · 4 comments · Fixed by #34

Comments

@kostia1st
Copy link

Issue

I'm a gentledev I:

  • fully read the README recently
  • searched for existing issues
  • checked I'm up to date with the latest version of the project

Expected behavior

There should not be any NonNullable<> wrappers around types that do not include nullable possibilities to begin with.

NonNullable<number>
NonNullable<string>
NonNullable<{ key: NonNullable<'value'> }>

do not make any practical sense, and just add up enormous amount of visual clutter in generated code, not to mention the bloated file size.

Actual behavior

Contrary of the above

Steps to reproduce the behavior

Generate typings against virtually any OpenAPI out there.

@nfroidure
Copy link
Owner

@kostia1st feel free to create a PR, it should sit around there: https://github.com/nfroidure/schema2dts/blob/main/src/index.ts#L1062C44-L1062C57

nfroidure added a commit that referenced this issue May 30, 2024
Use `null` literal to compose types intersections instead of using `NonNullable` for not nullable
fields. It should lead to a lighter type definition.

BREAKING CHANGE: Not sure if it really breaks anything but won't hurt to create a major version just
in case.

fix #33
@nfroidure
Copy link
Owner

@kostia1st I finally gave it a lil try, feel free to review: #34

@kostia1st
Copy link
Author

That looks great!

@nfroidure
Copy link
Owner

Just published the v6 then.

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 a pull request may close this issue.

2 participants