notion-sdk-js
notion-sdk-js copied to clipboard
Typescript error when assigning null to select property
trafficstars
For assigning a value to a select property that could be empty when creating a page, I'm doing:
"Year": {
select: !data.year ? null : { name: data.year }
},
and it works fine, the page gets created with an empty value, but typescript says that null is not assignable:

Hi @laripereira14 ! Thanks for filing an issue. We have tested this on our end and a request that looks like the following passes the typecheck:
const data: { year: string | null } = { year: "1882" };
const response = await notion.pages.create({
parent: {
database_id: "d0e59976398b4418a9fd56ed463012c4",
},
properties: {
Name: {
title: [
{
text: {
content: "hi",
},
},
],
},
Tags: {
select: !data.year ? null : { name: data.year },
},
},
});
Can you paste your entire request? There may be a type issue with another part of the request.