11/**
2- * @typedef {import('parse5').Node } P5Node
3- * @typedef {import('parse5').Document } P5Document
4- * @typedef {import('parse5').DocumentFragment } P5Fragment
5- * @typedef {import('parse5').DocumentType } P5Doctype
6- * @typedef {import('parse5').CommentNode } P5Comment
7- * @typedef {import('parse5').TextNode } P5Text
8- * @typedef {import('parse5').Element } P5Element
9- * @typedef {import('parse5').Attribute } P5Attribute
10- * @typedef {import('parse5').ParentNode } P5Parent
2+ * @typedef {import('parse5').DefaultTreeAdapterMap } DefaultTreeAdapterMap
3+ * @typedef {DefaultTreeAdapterMap['document'] } P5Document
4+ * @typedef {DefaultTreeAdapterMap['documentFragment'] } P5Fragment
5+ * @typedef {DefaultTreeAdapterMap['element'] } P5Element
6+ * @typedef {DefaultTreeAdapterMap['node'] } P5Node
7+ * @typedef {DefaultTreeAdapterMap['documentType'] } P5Doctype
8+ * @typedef {DefaultTreeAdapterMap['commentNode'] } P5Comment
9+ * @typedef {DefaultTreeAdapterMap['textNode'] } P5Text
10+ * @typedef {DefaultTreeAdapterMap['parentNode'] } P5Parent
11+ * @typedef {import('parse5/dist/common/token.js').Attribute } P5Attribute
1112 * @typedef {Exclude<P5Node, P5Document|P5Fragment> } P5Child
1213 * @typedef {import('property-information').Schema } Schema
1314 * @typedef {import('property-information').Info } Info
@@ -59,11 +60,12 @@ export function toParse5(tree, space) {
5960function root ( node , schema ) {
6061 /** @type {P5Document } */
6162 const p5 = {
63+ // @ts -expect-error: fine.
6264 nodeName : '#document' ,
65+ // @ts -expect-error: fine.
6366 mode : ( node . data || { } ) . quirksMode ? 'quirks' : 'no-quirks' ,
6467 childNodes : [ ]
6568 }
66- // @ts -expect-error Assume correct children.
6769 p5 . childNodes = all ( node . children , p5 , schema )
6870 return patch ( node , p5 )
6971}
@@ -75,8 +77,11 @@ function root(node, schema) {
7577 */
7678function fragment ( node , schema ) {
7779 /** @type {P5Fragment } */
78- const p5 = { nodeName : '#document-fragment' , childNodes : [ ] }
79- // @ts -expect-error Assume correct children.
80+ const p5 = {
81+ // @ts -expect-error: fine.
82+ nodeName : '#document-fragment' ,
83+ childNodes : [ ]
84+ }
8085 p5 . childNodes = all ( node . children , p5 , schema )
8186 return patch ( node , p5 )
8287}
@@ -87,11 +92,13 @@ function fragment(node, schema) {
8792 * @returns {P5Doctype }
8893 */
8994function doctype ( node ) {
95+ // @ts -expect-error: fine.
9096 return patch ( node , {
9197 nodeName : '#documentType' ,
9298 name : 'html' ,
9399 publicId : '' ,
94100 systemId : '' ,
101+ // @ts -expect-error: change to `null` in a major?
95102 parentNode : undefined
96103 } )
97104}
@@ -201,7 +208,6 @@ function element(node, schema) {
201208 } )
202209 )
203210
204- // @ts -expect-error Assume correct children.
205211 p5 . childNodes = all ( node . children , p5 , schema )
206212
207213 // @ts -expect-error Types are wrong.
@@ -228,7 +234,6 @@ function all(children, p5, schema) {
228234 // @ts -expect-error Assume child.
229235 const child = one ( children [ index ] , schema )
230236
231- // @ts -expect-error types are wrong.
232237 child . parentNode = p5
233238
234239 result . push ( child )
@@ -250,13 +255,14 @@ function patch(node, p5) {
250255 const position = node . position
251256
252257 if ( position && position . start && position . end ) {
253- // @ts -expect-error Types are wrong.
254258 p5 . sourceCodeLocation = {
255259 startLine : position . start . line ,
256260 startCol : position . start . column ,
261+ // @ts -expect-error assume this is set.
257262 startOffset : position . start . offset ,
258263 endLine : position . end . line ,
259264 endCol : position . end . column ,
265+ // @ts -expect-error assume this is set.
260266 endOffset : position . end . offset
261267 }
262268 }
0 commit comments