1
1
/**
2
- * @typedef {import('unified').CompilerFunction } CompilerFunction
3
- * @typedef {import('unified').Transformer } Transformer
4
- * @typedef {import('unist').Literal } Literal
2
+ * @typedef {import('unified').Compiler } Compiler
3
+ * @typedef {import('unist').Literal<string> } Literal
5
4
*/
6
5
7
6
import fs from 'fs'
@@ -26,14 +25,10 @@ test('output', (t) => {
26
25
27
26
engine (
28
27
{
29
- // @ts -expect-error: unified types are wrong.
30
28
processor : noop ( ) . use ( ( ) => {
31
- /**
32
- * @type {Transformer }
33
- * @param {Literal } tree
34
- */
35
29
return function ( tree ) {
36
- tree . value = 'two'
30
+ const text = /** @type {Literal } */ ( tree )
31
+ text . value = 'two'
37
32
}
38
33
} ) ,
39
34
cwd,
@@ -61,14 +56,10 @@ test('output', (t) => {
61
56
62
57
engine (
63
58
{
64
- // @ts -expect-error: unified types are wrong.
65
59
processor : noop ( ) . use ( ( ) => {
66
- /**
67
- * @type {Transformer }
68
- * @param {Literal } tree
69
- */
70
60
return function ( tree ) {
71
- tree . value = 'two'
61
+ const text = /** @type {Literal } */ ( tree )
62
+ text . value = 'two'
72
63
}
73
64
} ) ,
74
65
cwd,
@@ -96,14 +87,10 @@ test('output', (t) => {
96
87
97
88
engine (
98
89
{
99
- // @ts -expect-error: unified types are wrong.
100
90
processor : noop ( ) . use ( ( ) => {
101
- /**
102
- * @type {Transformer }
103
- * @param {Literal } tree
104
- */
105
91
return function ( tree ) {
106
- tree . value = 'two'
92
+ const text = /** @type {Literal } */ ( tree )
93
+ text . value = 'two'
107
94
}
108
95
} ) ,
109
96
cwd,
@@ -132,14 +119,10 @@ test('output', (t) => {
132
119
133
120
engine (
134
121
{
135
- // @ts -expect-error: unified types are wrong.
136
122
processor : noop ( ) . use ( ( ) => {
137
- /**
138
- * @type {Transformer }
139
- * @param {Literal } tree
140
- */
141
123
return function ( tree ) {
142
- tree . value = 'two'
124
+ const text = /** @type {Literal } */ ( tree )
125
+ text . value = 'two'
143
126
}
144
127
} ) ,
145
128
streamOut : stdout . stream ,
@@ -167,14 +150,10 @@ test('output', (t) => {
167
150
168
151
engine (
169
152
{
170
- // @ts -expect-error: unified types are wrong.
171
153
processor : noop ( ) . use ( ( ) => {
172
- /**
173
- * @type {Transformer }
174
- * @param {Literal } tree
175
- */
176
154
return function ( tree ) {
177
- tree . value = 'two'
155
+ const text = /** @type {Literal } */ ( tree )
156
+ text . value = 'two'
178
157
}
179
158
} ) ,
180
159
cwd,
@@ -205,14 +184,10 @@ test('output', (t) => {
205
184
206
185
engine (
207
186
{
208
- // @ts -expect-error: unified types are wrong.
209
187
processor : noop ( ) . use ( ( ) => {
210
- /**
211
- * @type {Transformer }
212
- * @param {Literal } tree
213
- */
214
188
return function ( tree ) {
215
- tree . value = 'two'
189
+ const text = /** @type {Literal } */ ( tree )
190
+ text . value = 'two'
216
191
}
217
192
} ) ,
218
193
cwd,
@@ -244,14 +219,10 @@ test('output', (t) => {
244
219
245
220
engine (
246
221
{
247
- // @ts -expect-error: unified types are wrong.
248
222
processor : noop ( ) . use ( ( ) => {
249
- /**
250
- * @type {Transformer }
251
- * @param {Literal } tree
252
- */
253
223
return function ( tree ) {
254
- tree . value = 'two'
224
+ const text = /** @type {Literal } */ ( tree )
225
+ text . value = 'two'
255
226
}
256
227
} ) ,
257
228
cwd,
@@ -323,14 +294,10 @@ test('output', (t) => {
323
294
324
295
engine (
325
296
{
326
- // @ts -expect-error: unified types are wrong.
327
297
processor : noop ( ) . use ( ( ) => {
328
- /**
329
- * @type {Transformer }
330
- * @param {Literal } tree
331
- */
332
298
return function ( tree ) {
333
- tree . value = 'two'
299
+ const text = /** @type {Literal } */ ( tree )
300
+ text . value = 'two'
334
301
}
335
302
} ) ,
336
303
cwd,
@@ -360,14 +327,10 @@ test('output', (t) => {
360
327
361
328
engine (
362
329
{
363
- // @ts -expect-error: unified types are wrong.
364
330
processor : noop ( ) . use ( ( ) => {
365
- /**
366
- * @type {Transformer }
367
- * @param {Literal } tree
368
- */
369
331
return function ( tree , file ) {
370
- tree . value = 'two'
332
+ const text = /** @type {Literal } */ ( tree )
333
+ text . value = 'two'
371
334
file . history = [ ]
372
335
}
373
336
} ) ,
@@ -494,12 +457,12 @@ test('output', (t) => {
494
457
495
458
engine (
496
459
{
497
- // @ts -expect-error: unified types are wrong.
498
460
processor : noop ( ) . use ( function ( ) {
499
- /** @type {CompilerFunction } */
500
- this . Compiler = function ( ) {
501
- return Buffer . from ( 'bravo' )
502
- }
461
+ Object . assign ( this , {
462
+ Compiler ( ) {
463
+ return Buffer . from ( 'bravo' )
464
+ }
465
+ } )
503
466
} ) ,
504
467
cwd,
505
468
streamOut : stdout . stream ,
@@ -526,12 +489,12 @@ test('output', (t) => {
526
489
527
490
engine (
528
491
{
529
- // @ts -expect-error: unified types are wrong.
530
492
processor : noop ( ) . use ( function ( ) {
531
- /** @type {CompilerFunction } */
532
- this . Compiler = function ( ) {
533
- return null
534
- }
493
+ Object . assign ( this , {
494
+ Compiler ( ) {
495
+ return null
496
+ }
497
+ } )
535
498
} ) ,
536
499
cwd,
537
500
streamOut : stdout . stream ,
@@ -558,12 +521,12 @@ test('output', (t) => {
558
521
559
522
engine (
560
523
{
561
- // @ts -expect-error: unified types are wrong.
562
524
processor : noop ( ) . use ( function ( ) {
563
- /** @type {CompilerFunction } */
564
- this . Compiler = function ( ) {
565
- return { type : 'some-virtual-dom' }
566
- }
525
+ Object . assign ( this , {
526
+ Compiler ( ) {
527
+ return { type : 'some-virtual-dom' }
528
+ }
529
+ } )
567
530
} ) ,
568
531
cwd,
569
532
streamOut : stdout . stream ,
0 commit comments