index/functions/buildSafePaginationOptions.md
buildSafePaginationOptions(
options):BasePaginationOptions
Safely build pagination options without passing undefined
This helper ensures that optional pagination fields are only included when they have actual values, complying with exactOptionalPropertyTypes.
base pagination options
Parameters
| Parameter | Type | Description |
|---|---|---|
options | Partial<BasePaginationOptions> | Partial pagination options (may have undefined values) |
base pagination options
Returns
Clean pagination options object without undefined properties
base pagination options
Example
const cursor = getCursorFromSomewhere() || undefined;
const pageSize = getPageSize();
// This would cause TS2379 error:
// const options: BasePaginationOptions = { cursor, pageSize };
// Use this helper instead:
const options = buildSafePaginationOptions({
cursor, // May be undefined
pageSize
});
// Result has no undefined values
Since
8.0.0