1
1
/**
2
- * @typedef {import('hast').Comment } Comment
3
- * @typedef {import('hast').Doctype } Doctype
4
- * @typedef {import('hast').Element } Element
5
- * @typedef {import('hast').Nodes } Nodes
6
- * @typedef {import('hast').Root } Root
7
- * @typedef {import('hast').RootContent } RootContent
8
- * @typedef {import('hast').Text } Text
9
- *
10
- * @typedef {import('hast-util-raw').Options } Options
11
- *
12
- * @typedef {import('mdast-util-to-hast').Raw } Raw
13
- *
14
- * @typedef {import('parse5').DefaultTreeAdapterMap } DefaultTreeAdapterMap
15
- * @typedef {import('parse5').ParserOptions<DefaultTreeAdapterMap> } ParserOptions
16
- * @typedef {import('parse5').Token.CharacterToken } CharacterToken
17
- * @typedef {import('parse5').Token.CommentToken } CommentToken
18
- * @typedef {import('parse5').Token.DoctypeToken } DoctypeToken
19
- * @typedef {import('parse5').Token.Location } Location
20
- * @typedef {import('parse5').Token.TagToken } TagToken
21
- *
22
- * @typedef {import('unist').Point } Point
2
+ * @import {Comment, Doctype, Element, Nodes, RootContent, Root, Text} from 'hast'
3
+ * @import {Options} from 'hast-util-raw'
4
+ * @import {Raw} from 'mdast-util-to-hast'
5
+ * @import {DefaultTreeAdapterMap, ParserOptions} from 'parse5'
6
+ * @import {Point} from 'unist'
23
7
*/
24
8
25
9
/**
@@ -65,7 +49,7 @@ const knownMdxNames = new Set([
65
49
'mdxjsEsm'
66
50
] )
67
51
68
- /** @type {ParserOptions } */
52
+ /** @type {ParserOptions<DefaultTreeAdapterMap> } */
69
53
const parseOptions = { sourceCodeLocationInfo : true , scriptingEnabled : false }
70
54
71
55
/**
@@ -206,7 +190,7 @@ function text(node, state) {
206
190
state . parser . tokenizer . state = 0
207
191
}
208
192
209
- /** @type {CharacterToken } */
193
+ /** @type {Token. CharacterToken } */
210
194
const token = {
211
195
type : Token . TokenType . CHARACTER ,
212
196
chars : node . value ,
@@ -233,7 +217,7 @@ function text(node, state) {
233
217
* Nothing.
234
218
*/
235
219
function doctype ( node , state ) {
236
- /** @type {DoctypeToken } */
220
+ /** @type {Token. DoctypeToken } */
237
221
const token = {
238
222
type : Token . TokenType . DOCTYPE ,
239
223
name : 'html' ,
@@ -300,7 +284,7 @@ function comment(node, state) {
300
284
// @ts -expect-error: we pass stitches through.
301
285
const data = node . value
302
286
303
- /** @type {CommentToken } */
287
+ /** @type {Token. CommentToken } */
304
288
const token = {
305
289
type : Token . TokenType . COMMENT ,
306
290
data,
@@ -427,7 +411,7 @@ function resetTokenizer(state, point) {
427
411
setPoint ( state , point )
428
412
429
413
// Process final characters if they’re still there after hibernating.
430
- /** @type {CharacterToken } */
414
+ /** @type {Token. CharacterToken } */
431
415
// @ts -expect-error: private.
432
416
// type-coverage:ignore-next-line
433
417
const token = state . parser . tokenizer . currentCharacterToken
@@ -496,7 +480,7 @@ function resetTokenizer(state, point) {
496
480
*/
497
481
function setPoint ( state , point ) {
498
482
if ( point && point . offset !== undefined ) {
499
- /** @type {Location } */
483
+ /** @type {Token. Location } */
500
484
const location = {
501
485
startLine : point . line ,
502
486
startCol : point . column ,
@@ -548,7 +532,7 @@ function startTag(node, state) {
548
532
{ space : ns === webNamespaces . svg ? 'svg' : 'html' }
549
533
)
550
534
551
- /** @type {TagToken } */
535
+ /** @type {Token. TagToken } */
552
536
const tag = {
553
537
type : Token . TokenType . START_TAG ,
554
538
tagName,
@@ -608,7 +592,7 @@ function endTag(node, state) {
608
592
609
593
resetTokenizer ( state , pointEnd ( node ) )
610
594
611
- /** @type {TagToken } */
595
+ /** @type {Token. TagToken } */
612
596
const tag = {
613
597
type : Token . TokenType . END_TAG ,
614
598
tagName,
@@ -672,7 +656,7 @@ function documentMode(node) {
672
656
*
673
657
* @param {Nodes | Stitch } node
674
658
* hast node.
675
- * @returns {Location }
659
+ * @returns {Token. Location }
676
660
* `parse5` location.
677
661
*/
678
662
function createParse5Location ( node ) {
@@ -687,7 +671,7 @@ function createParse5Location(node) {
687
671
offset : undefined
688
672
}
689
673
690
- /** @type {Record<keyof Location, number | undefined> } */
674
+ /** @type {Record<keyof Token. Location, number | undefined> } */
691
675
const location = {
692
676
startLine : start . line ,
693
677
startCol : start . column ,
0 commit comments