The generated types look like so
export type ListSitesRequest = {
// Behaviors: REQUIRED
parent: string | undefined;
// Behaviors: OPTIONAL
pageSize: number | undefined;
// Behaviors: OPTIONAL
pageToken: string | undefined;
};
which means typescript will make you initialize each field, even if you intend to keep it undefined
const a: ListSitesRequest = {parent: "foo/bar"}; // Type '{ parent: string; }' is missing the following properties from type 'ListSitesRequest': pageSize, pageToken
const a: ListSitesRequest = {parent: "foo/bar", pageSize: undefined, pageToken: undefined}; // passes
Alternatively we could generate the optional fields this way:
export type ListSitesRequest = {
// Behaviors: REQUIRED
parent?: string;
// Behaviors?=: OPTIONAL
pageSize?: number;
// Behaviors: OPTIONAL
pageToken?: string;
};
which would allow field omission for fields that the caller does not want to supply.
Is the current behavior a stylistic choice, or would we be open to changing it?
The generated types look like so
which means typescript will make you initialize each field, even if you intend to keep it undefined
Alternatively we could generate the optional fields this way:
which would allow field omission for fields that the caller does not want to supply.
Is the current behavior a stylistic choice, or would we be open to changing it?