isDocument
See source codeType guard to check if a record is a TLDocument. Useful for filtering or type narrowing when working with mixed record types.
function isDocument(record?: UnknownRecord): record is TLDocument
Example
// Type guard usage
function processRecord(record: UnknownRecord) {
if (isDocument(record)) {
// record is now typed as TLDocument
console.log(`Document: ${record.name}, Grid: ${record.gridSize}px`)
}
}
// Filter documents from mixed records
const allRecords = store.allRecords()
const documents = allRecords.filter(isDocument) // Should be exactly one
Parameters
Name | Description |
---|---|
| The record to check |
Returns
record is TLDocument
True if the record is a document, false otherwise
Prev
isBindingIdNext
isPageId