You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It's fairly easy when refactoring nullable variables to miss somewhere that it's supposed to be changed. For non-nullable variables, there's a fairly reliable catch - as the variable is required to be provided to the query.run(params, conn) function, Typescript will raise an error.
However, if the variable is nullable, as of #482 nullable variables are now optional, so they do not raise an error if you provide a variable with the wrong name (typescript's excess property checking often does not catch these cases, never for me 😞).
Describe the solution you'd like
Provide a feature flag to the config file to remove the optional parameter type for nullable types. Something like noOptionalParameters: boolean.
I'm just testing if you'll like this feature, or if you'll want a different name for the flag. I can take responsibility for writing it, it's a very easy PR to make - prob <10 lines of code changes, and a few tests.
The text was updated successfully, but these errors were encountered:
I'd really love this feature. I recently wrote an upsert query and missed a ! on one of parameters required for the insert part. Despite the column being not null in postgres, the generated typescript type key was marked optional and so it compiled cleanly and then the query failed at runtime for having a null value.
The majority of our columns are marked not null. I'd love a setting in pgtyped that assumes all parameters in the query are not optional unless they have a question mark like $parameter?.
That said, is there a reason pg-typed can't determine whether a parameter is required/optional from the query itself?
Is your feature request related to a problem? Please describe.
It's fairly easy when refactoring nullable variables to miss somewhere that it's supposed to be changed. For non-nullable variables, there's a fairly reliable catch - as the variable is required to be provided to the
query.run(params, conn)
function, Typescript will raise an error.However, if the variable is nullable, as of #482 nullable variables are now optional, so they do not raise an error if you provide a variable with the wrong name (typescript's excess property checking often does not catch these cases, never for me 😞).
Describe the solution you'd like
Provide a feature flag to the config file to remove the optional parameter type for nullable types. Something like
noOptionalParameters: boolean
.I'm just testing if you'll like this feature, or if you'll want a different name for the flag. I can take responsibility for writing it, it's a very easy PR to make - prob <10 lines of code changes, and a few tests.
The text was updated successfully, but these errors were encountered: