-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix null contentRef handling in RecordColumnValue #3566
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we are fixing at the right place; I always oppose all changes that go into fixing data problems in places where we should trust the types.
The real problem here is that the API outputs something it should not; let's fix this.
@@ -110,3 +110,7 @@ export function getColumnVerticalAlignment(column: DocumentTableDefinition): Ver | |||
|
|||
return 'self-center'; | |||
} | |||
|
|||
export function isContentRef(ref: DocumentTableRecord['values'][string]): ref is ContentRef { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, why do we need this?
We should not have to check types dynamically; the API should return what it says. Otherwise it's a problem on GBX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Steven already made the change in GBX to the API https://github.com/GitbookIO/gitbook-x/pull/19236.
isContentRef
is not necessarily needed, ref
can be null | ContentRef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think the isContentRef
is the good solution here, by nature we can't easily type a Table as it is a user created type.
The type of DocumentTableRecord['values'][string]
is string | number | boolean | string[] | ContentRef | null
Not sure if we can type this one that much better without overcomplicating things
Improve handling of contentRef to prevent null values and ensure proper resolution in the RecordColumnValue function. Introduce a utility function to validate contentRef objects.