|
1 | 1 | /** |
2 | | - * @typedef {JSX.IntrinsicElements} IntrinsicElements |
3 | 2 | * @typedef {import('react').ReactNode} ReactNode |
4 | 3 | * @typedef {import('unist').Position} Position |
5 | 4 | * @typedef {import('hast').Element} Element |
| 5 | + * @typedef {import('hast').ElementContent} ElementContent |
6 | 6 | * @typedef {import('hast').Root} Root |
7 | 7 | * @typedef {import('hast').Text} Text |
8 | 8 | * @typedef {import('hast').Comment} Comment |
9 | 9 | * @typedef {import('hast').DocType} Doctype |
10 | 10 | * @typedef {import('property-information').Info} Info |
11 | 11 | * @typedef {import('property-information').Schema} Schema |
| 12 | + * @typedef {import('./complex-types').ReactMarkdownProps} ReactMarkdownProps |
12 | 13 | * |
13 | 14 | * @typedef Raw |
14 | 15 | * @property {'raw'} type |
|
21 | 22 | * |
22 | 23 | * @callback TransformLink |
23 | 24 | * @param {string} href |
24 | | - * @param {Array.<Comment|Element|Text>} children |
| 25 | + * @param {Array.<ElementContent>} children |
25 | 26 | * @param {string?} title |
26 | 27 | * @returns {string} |
27 | 28 | * |
|
33 | 34 | * |
34 | 35 | * @callback TransformLinkTarget |
35 | 36 | * @param {string} href |
36 | | - * @param {Array.<Comment|Element|Text>} children |
| 37 | + * @param {Array.<ElementContent>} children |
37 | 38 | * @param {string?} title |
38 | 39 | * @returns {string|undefined} |
39 | 40 | * |
40 | | - * @typedef {keyof IntrinsicElements} ReactMarkdownNames |
| 41 | + * @typedef {keyof JSX.IntrinsicElements} ReactMarkdownNames |
41 | 42 | * |
42 | 43 | * To do: is `data-sourcepos` typeable? |
43 | 44 | * |
44 | | - * @typedef ReactMarkdownProps |
45 | | - * @property {Element} node |
46 | | - * @property {string} key |
47 | | - * @property {ReactNode[]} children |
48 | | - * @property {Position?} [sourcePosition] Passed when `options.rawSourcePos` is given |
49 | | - * @property {number} [index] Passed when `options.includeElementIndex` is given |
50 | | - * @property {number} [siblingCount] Passed when `options.includeElementIndex` is given |
51 | | - * |
52 | 45 | * @callback CodeComponent |
53 | 46 | * @param {JSX.IntrinsicElements['code'] & ReactMarkdownProps & {inline?: boolean}} props |
54 | 47 | * @returns {ReactNode} |
|
92 | 85 | * @property {TableRowComponent|ReactMarkdownNames} tr |
93 | 86 | * @property {UnorderedListComponent|ReactMarkdownNames} ul |
94 | 87 | * |
95 | | - * @typedef {{[TagName in keyof IntrinsicElements]: TagName | ((props: IntrinsicElements[TagName] & ReactMarkdownProps) => ReactNode)}} NormalComponents |
96 | | - * @typedef {Partial<Omit<NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components |
| 88 | + * @typedef {Partial<Omit<import("./complex-types").NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components |
97 | 89 | * |
98 | 90 | * @typedef Options |
99 | 91 | * @property {boolean} [sourcePos=false] |
@@ -145,10 +137,8 @@ export function childrenToReact(context, node) { |
145 | 137 | ) { |
146 | 138 | children.push(child.value) |
147 | 139 | } |
148 | | - // @ts-expect-error `raw` nodes are non-standard |
149 | 140 | } else if (child.type === 'raw' && !context.options.skipHtml) { |
150 | 141 | // Default behavior is to show (encoded) HTML. |
151 | | - // @ts-expect-error `raw` nodes are non-standard |
152 | 142 | children.push(child.value) |
153 | 143 | } |
154 | 144 | } |
@@ -201,7 +191,7 @@ function toReact(context, node, index, parent) { |
201 | 191 | context.schema = parentSchema |
202 | 192 |
|
203 | 193 | // Nodes created by plugins do not have positional info, in which case we use |
204 | | - // an object that matches the positon interface. |
| 194 | + // an object that matches the position interface. |
205 | 195 | const position = node.position || { |
206 | 196 | start: {line: null, column: null, offset: null}, |
207 | 197 | end: {line: null, column: null, offset: null} |
|
0 commit comments