Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types from DatabasePropertyConfigResponse union require a description #504

Open
borisghidaglia opened this issue Apr 30, 2024 · 0 comments

Comments

@borisghidaglia
Copy link

borisghidaglia commented Apr 30, 2024

Describe the bug
Types from DatabasePropertyConfigResponse union require a description property.
Example here.

However, the description property is not (always?) returned in the response if no description is provided on a notion db.

To Reproduce
Node version: v21.7.3
Notion JS library version: 2.2.15

Steps to reproduce the behavior:

  • retrieve a db using await client.databases.retrieve({ database_id: id }) and save this data as a TS const somewhere.
  • add the satisfies operator like this:
const notionData = {...} satisfies GetDatabaseResponse; 

For property types, you will get this error (as an example with RichTextDatabasePropertyConfigResponse):
Property 'description' is missing in type '{ id: string; name: string; type: "rich_text"; rich_text: {}; }' but required in type 'RichTextDatabasePropertyConfigResponse'

Expected behavior
satisfies GetDatabaseResponse on the data should work as client.databases.retrieve returns a Promise<GetDatabaseResponse>.

Additional context
It seems that description has been added in v2.2.15. See commit 4a21f8a which is part of the release.

Potential fixes
Today, description is defined like this:

description: PropertyDescriptionRequest | null

Thus, the API could always return the description field and set it to null if there is no description.
Or, the type could be fixed as such:

- description: PropertyDescriptionRequest | null
+ description?: PropertyDescriptionRequest | null

But then maybe we could also remove null and get rid of the union?

@borisghidaglia borisghidaglia changed the title Types from DatabasePropertyConfigResponse union require a description and Types from DatabasePropertyConfigResponse union require a description Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant