@@ -269,11 +269,14 @@ Raw string of HTML embedded into HTML AST (TypeScript).
269269###### Type
270270
271271` ` ` ts
272- import type {Literal } from ' hast'
272+ import type {Data , Literal } from ' hast'
273273
274274interface Raw extends Literal {
275275 type: ' raw'
276+ data? : RawData | undefined
276277}
278+
279+ interface RawData extends Data {}
277280```
278281
279282### ` State `
@@ -1341,10 +1344,10 @@ Raw nodes are typically ignored but are handled by
13411344## Types
13421345
13431346This package is fully typed with [ TypeScript] [ ] .
1344- It also exports [ ` Handler ` ] [ api-handler ] , [ ` Handlers ` ] [ api-handlers ] ,
1347+ It exports the [ ` Handler ` ] [ api-handler ] , [ ` Handlers ` ] [ api-handlers ] ,
13451348[ ` Options ` ] [ api-options ] , [ ` Raw ` ] [ api-raw ] , and [ ` State ` ] [ api-state ] types.
13461349
1347- It also registers the ` Raw ` node type with ` @types/mdast ` .
1350+ It also registers the ` Raw ` node type with ` @types/hast ` .
13481351If you’re working with the syntax tree (and you pass
13491352` allowDangerousHtml: true ` ), make sure to import this utility somewhere in your
13501353types, as that registers the new node type in the tree.
@@ -1364,6 +1367,24 @@ visit(tree, function (node) {
13641367})
13651368```
13661369
1370+ Finally, it also registers the ` hChildren ` , ` hName ` , and ` hProperties ` fields
1371+ on ` Data ` of ` @types/mdast ` .
1372+ If you’re working with the syntax tree, make sure to import this utility
1373+ somewhere in your types, as that registers the data fields in the tree.
1374+
1375+ ``` js
1376+ /**
1377+ * @typedef {import('mdast-util-to-hast')}
1378+ */
1379+
1380+ import {visit } from ' unist-util-visit'
1381+
1382+ /** @type {import('hast').Root} */
1383+ const tree = { /* … */ }
1384+
1385+ console .log (tree .data ? .hName ) // Types as `string | undefined`.
1386+ ` ` `
1387+
13671388## Compatibility
13681389
13691390Projects maintained by the unified collective are compatible with maintained
0 commit comments