Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0695ae3

Browse files
authoredFeb 6, 2025··
fix(typeError): Marking markDefs as optional to resolve TS error when markDefs array is missing (#96)
1 parent ff05e43 commit 0695ae3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/buildMarksTree.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import type {
44
PortableTextMarkDefinition,
55
} from '@portabletext/types'
66

7-
import {isPortableTextSpan} from './asserters'
8-
import {sortMarksByOccurences} from './sortMarksByOccurences'
9-
import type {ToolkitNestedPortableTextSpan, ToolkitTextNode} from './types'
7+
import { isPortableTextSpan } from './asserters'
8+
import { sortMarksByOccurences } from './sortMarksByOccurences'
9+
import type { ToolkitNestedPortableTextSpan, ToolkitTextNode } from './types'
1010

1111
/**
1212
* Takes a Portable Text block and returns a nested tree of nodes optimized for rendering
@@ -90,7 +90,7 @@ export function buildMarksTree<M extends PortableTextMarkDefinition = PortableTe
9090
}
9191

9292
for (const markKey of marksNeeded) {
93-
const markDef = markDefs.find((def) => def._key === markKey)
93+
const markDef = markDefs?.find((def) => def._key === markKey)
9494
const markType = markDef ? markDef._type : markKey
9595
const node: ToolkitNestedPortableTextSpan<M> = {
9696
_type: '@span',

0 commit comments

Comments
 (0)
Please sign in to comment.