Here, line2 is properly identified as string | undefined | null, but the property itself is not properly marked as optional. Consequently, if I supply an object to createAddress.run that has an optional line2 property, the TypeScript compiler complains even though everything is fine at runtime.
The Solution
I think the simple fix would be to let TypeScript know that nullable parameters/properties are optional. The way to do that would be with a ? So ideally, the following would be generated for optional properties
/** 'CreateAddress' parameters type */
export interface ICreateAddressParams {
address: {
// ... Other Properties
line2?: string | null | void, // notice the `?`
};
}
The Problem
Currently, when generating TS files from SQL queries, the TS types require nullable parameters to be specified. For example
Generates the following type
Here,
line2
is properly identified asstring | undefined | null
, but the property itself is not properly marked as optional. Consequently, if I supply an object tocreateAddress.run
that has an optionalline2
property, the TypeScript compiler complains even though everything is fine at runtime.The Solution
I think the simple fix would be to let TypeScript know that nullable parameters/properties are optional. The way to do that would be with a
?
So ideally, the following would be generated for optional properties