22 * @typedef {import('unist').Node } Node
33 * @typedef {import('unist').Literal<string> } Literal
44 * @typedef {import('mdast').Root } Root
5+ * @typedef {import('mdast').Text } Text
56 * @typedef {import('mdast').InlineCode } InlineCode
67 * @typedef {import('vfile').VFile } VFile
78 */
@@ -25,7 +26,7 @@ import {toNlcst} from '../index.js'
2526test ( 'mdast-util-to-nlcst' , ( t ) => {
2627 t . throws (
2728 ( ) => {
28- // @ts -expect-error runtime.
29+ // @ts -expect-error runtime: too few arguments .
2930 toNlcst ( )
3031 } ,
3132 / m d a s t - u t i l - t o - n l c s t e x p e c t e d n o d e / ,
@@ -34,7 +35,7 @@ test('mdast-util-to-nlcst', (t) => {
3435
3536 t . throws (
3637 ( ) => {
37- // @ts -expect-error runtime.
38+ // @ts -expect-error runtime: too few arguments .
3839 toNlcst ( { } )
3940 } ,
4041 / m d a s t - u t i l - t o - n l c s t e x p e c t e d n o d e / ,
@@ -43,7 +44,7 @@ test('mdast-util-to-nlcst', (t) => {
4344
4445 t . throws (
4546 ( ) => {
46- // @ts -expect-error runtime.
47+ // @ts -expect-error runtime: too few arguments .
4748 toNlcst ( { type : 'foo' } )
4849 } ,
4950 / m d a s t - u t i l - t o - n l c s t e x p e c t e d f i l e / ,
@@ -52,7 +53,7 @@ test('mdast-util-to-nlcst', (t) => {
5253
5354 t . throws (
5455 ( ) => {
55- // @ts -expect-error runtime.
56+ // @ts -expect-error runtime: too few arguments .
5657 toNlcst ( { type : 'foo' } )
5758 } ,
5859 / m d a s t - u t i l - t o - n l c s t e x p e c t e d f i l e / ,
@@ -61,7 +62,7 @@ test('mdast-util-to-nlcst', (t) => {
6162
6263 t . throws (
6364 ( ) => {
64- // @ts -expect-error runtime.
65+ // @ts -expect-error runtime: too few arguments .
6566 toNlcst ( { type : 'text' , value : 'foo' } , { foo : 'bar' } )
6667 } ,
6768 / m d a s t - u t i l - t o - n l c s t e x p e c t e d f i l e / ,
@@ -70,9 +71,9 @@ test('mdast-util-to-nlcst', (t) => {
7071
7172 t . throws (
7273 ( ) => {
73- // @ts -expect-error runtime.
74+ // @ts -expect-error runtime: too few arguments .
7475 toNlcst (
75- /** @type {Literal } */ ( { type : 'text' , value : 'foo' } ) ,
76+ /** @type {Text } */ ( { type : 'text' , value : 'foo' } ) ,
7677 vfile ( { contents : 'foo' } )
7778 )
7879 } ,
@@ -83,7 +84,7 @@ test('mdast-util-to-nlcst', (t) => {
8384 t . throws (
8485 ( ) => {
8586 toNlcst (
86- /** @type {Literal } */ ( { type : 'text' , value : 'foo' } ) ,
87+ /** @type {Text } */ ( { type : 'text' , value : 'foo' } ) ,
8788 vfile ( ) ,
8889 ParseLatin
8990 )
@@ -94,7 +95,7 @@ test('mdast-util-to-nlcst', (t) => {
9495
9596 t . doesNotThrow ( ( ) => {
9697 toNlcst (
97- /** @type {Literal } */ ( {
98+ /** @type {Text } */ ( {
9899 type : 'text' ,
99100 value : 'foo' ,
100101 position : { start : { line : 1 , column : 1 } , end : { line : 1 , column : 4 } }
@@ -106,7 +107,7 @@ test('mdast-util-to-nlcst', (t) => {
106107
107108 t . doesNotThrow ( ( ) => {
108109 toNlcst (
109- /** @type {Literal } */ ( {
110+ /** @type {Text } */ ( {
110111 type : 'text' ,
111112 value : 'foo' ,
112113 position : { start : { line : 1 , column : 1 } , end : { line : 1 , column : 4 } }
@@ -122,7 +123,7 @@ test('mdast-util-to-nlcst', (t) => {
122123 {
123124 type : 'text' ,
124125 value : 'foo' ,
125- // @ts -expect-error runtime.
126+ // @ts -expect-error runtime: incorrect positional info .
126127 position : { start : { } , end : { } }
127128 } ,
128129 vfile ( ) ,
@@ -225,40 +226,30 @@ test('Fixtures', (t) => {
225226 const base = path . join ( 'test' , 'fixtures' )
226227 const files = fs . readdirSync ( base )
227228 let index = - 1
228- /** @type {string } */
229- let name
230- /** @type {VFile } */
231- let input
232- /** @type {Node } */
233- let expected
234- /** @type {Node } */
235- let mdast
236- /** @type {Object.<string, unknown>|undefined } */
237- let options
238229
239230 while ( ++ index < files . length ) {
240- name = files [ index ]
231+ const name = files [ index ]
232+ /** @type {Object.<string, unknown>|undefined } */
233+ let options
241234
242235 if ( isHidden ( name ) ) continue
243236
244- input = vfile . readSync ( path . join ( base , name , 'input.md' ) )
245- expected = JSON . parse (
237+ const input = vfile . readSync ( path . join ( base , name , 'input.md' ) )
238+ /** @type {Node } */
239+ const expected = JSON . parse (
246240 String ( vfile . readSync ( path . join ( base , name , 'output.json' ) ) )
247241 )
248242
249243 try {
250244 options = JSON . parse (
251245 String ( vfile . readSync ( path . join ( base , name , 'options.json' ) ) )
252246 )
253- } catch {
254- options = undefined
255- }
247+ } catch { }
256248
257249 const processor = remark ( )
258250 if ( options && options . useRemarkGfm ) processor . use ( gfm )
259251 if ( options && options . useRemarkFrontmatter ) processor . use ( frontmatter )
260-
261- mdast = processor . parse ( input )
252+ const mdast = /** @type {Root } */ ( processor . parse ( input ) )
262253
263254 t . deepEqual (
264255 toNlcst ( mdast , input , ParseLatin , options ) ,
0 commit comments