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
Report bugs here only for the Node JavaScript library.
If you're having problems using Notion's API, or have any other feedback about the API including feature requests for the JavaScript library, please email support at developers@makenotion.com.
Describe the bug
When calling something like database.query that receives a cursor as a parameter, its type is string | undefined as it's start_cursor:?string. However, the returned cursor from the response is of type string | null. This causes issues when looping to obtain multiple pages while reassigning the cursor variable as the initial typing of the cursor variable will conflict with one of these.
I checked the type definitions and this is the case for all calls that receive and return a cursor. This is easy to workaround but it degrades the typing experience a little.
To Reproduce
Node version:
Notion JS library version:
2.2.14
Steps to reproduce the behavior:
let databaseId = '<some_id>';
let entries = [];
let cursor: string | null = null;
let entries = [];
while (true) {
const { results, has_more, next_cursor } = await this.notion.databases.query({
database_id: databaseId,
start_cursor: cursor
});
cursor = next_cursor;
entries.push(...results);
if (!has_more) {
break;
}
}
return entries;
Expected behavior
Expected: No typing issues
Got: Type 'string | null' is not assignable to type 'string | undefined'.
If we change the type of the cursor to be string | undefined then the error happens at cursor = next_cursor saying: Type 'string | undefined' is not assignable to type 'string | null'.
Additional context
Happy to make a PR for this :)
The text was updated successfully, but these errors were encountered:
Sho-ki
added a commit
to Sho-ki/notion-sdk-js
that referenced
this issue
May 5, 2024
Report bugs here only for the Node JavaScript library.
If you're having problems using Notion's API, or have any other feedback about the API including feature requests for the JavaScript library, please email support at developers@makenotion.com.
Describe the bug
When calling something like
database.query
that receives a cursor as a parameter, its type isstring | undefined
as it'sstart_cursor:?string
. However, the returned cursor from the response is of typestring | null
. This causes issues when looping to obtain multiple pages while reassigning the cursor variable as the initial typing of the cursor variable will conflict with one of these.I checked the type definitions and this is the case for all calls that receive and return a cursor. This is easy to workaround but it degrades the typing experience a little.
To Reproduce
Node version:
Notion JS library version:
2.2.14
Steps to reproduce the behavior:
Expected behavior
Expected: No typing issues
Got: Type 'string | null' is not assignable to type 'string | undefined'.
If we change the type of the cursor to be
string | undefined
then the error happens atcursor = next_cursor
saying:Type 'string | undefined' is not assignable to type 'string | null'.
Additional context
Happy to make a PR for this :)
The text was updated successfully, but these errors were encountered: