-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
Use unknown instead of any for additional properties type #1464
Comments
Totally agree with this change. I think this is the correct file: https://github.com/anymaniax/orval/blob/master/packages/core/src/getters/object.ts Simply replace all instances of |
PR is welcome. |
I opened #1466 |
Is it configurable? Is there anyway I can override this in a mutator? How do you guys handle this in a nice way? |
Not configurable. Asserting is a superior alternative because Previously doing something like this was fine: You must narrow the type or assert it. I usually prefer to go with what's simplest given the situation Further reading: |
Is it possible to override the input or write a output.override.transformer for example? |
What are the steps to reproduce this issue?
Create an openapi spec with an object that has additionalProperties set to true:
What happens?
The generated type will be
What were you expecting to happen?
I would have liked to have
unkown
instead ofany
:Having
any
disables all type checks on these values, and sinceany
propagates it can hide errors pretty far in the codebase that could have been caught otherwise.Having
unknown
forces the developer to handle all possible type cases. If they decide to then cast the values asany
it's then their choice but by default they'll have a strictly typed codebase.Any logs, error output, etc?
…
Any other comments?
We could make this configurable of course, but if not I have a small PR ready replacing the hardcoded
[key: string]: any
with[key: string]: unknown
.What versions are you using?
Operating System: …
Package Version: v6.30.2
Browser Version: …
The text was updated successfully, but these errors were encountered: