@@ -10,8 +10,10 @@ import {webNamespaces as ns} from 'web-namespaces'
1010import { u } from 'unist-builder'
1111import h from 'hyperscript'
1212import { h as v } from 'virtual-dom'
13+ // @ts -expect-error: hush
1314import vs from 'virtual-dom/virtual-hyperscript/svg.js'
1415import rehype from 'rehype'
16+ // @ts -expect-error: hush
1517import vToString from 'vdom-to-html'
1618import { createElement as r } from 'react'
1719import { renderToStaticMarkup as rToString } from 'react-dom/server.js'
@@ -26,6 +28,7 @@ test('hast-to-hyperscript', (t) => {
2628
2729 t . test ( 'should throw if not given h' , ( t ) => {
2830 t . throws ( ( ) => {
31+ // @ts -expect-error: runtime
2932 toH ( null , u ( 'element' , { tagName : '' } , [ ] ) )
3033 } , / h i s n o t a f u n c t i o n / )
3134
@@ -34,17 +37,17 @@ test('hast-to-hyperscript', (t) => {
3437
3538 t . test ( 'should throw if not given a node' , ( t ) => {
3639 t . throws ( ( ) => {
37- // @ts -ignore runtime.
40+ // @ts -expect-error runtime.
3841 toH ( h )
3942 } , / E x p e c t e d r o o t o r e l e m e n t , n o t ` u n d e f i n e d ` / )
4043
4144 t . throws ( ( ) => {
42- // @ts -ignore runtime.
45+ // @ts -expect-error runtime.
4346 toH ( h , u ( 'text' , 'Alpha' ) )
4447 } , / E r r o r : E x p e c t e d r o o t o r e l e m e n t , n o t ` t e x t ` / )
4548
4649 t . throws ( ( ) => {
47- // @ts -ignore runtime.
50+ // @ts -expect-error runtime.
4851 toH ( h , u ( 'text' , 'value' ) )
4952 } , / E x p e c t e d r o o t o r e l e m e n t / )
5053
@@ -180,7 +183,7 @@ test('hast-to-hyperscript', (t) => {
180183 )
181184 ] )
182185
183- // @ts -ignore `outerHTML` definitely does exist.
186+ // @ts -expect-error `outerHTML` definitely does exist.
184187 t . deepEqual ( html ( actual . outerHTML ) , html ( baseline ) , 'equal output' )
185188
186189 t . deepEqual (
@@ -194,13 +197,15 @@ test('hast-to-hyperscript', (t) => {
194197
195198 t . test ( 'should support `virtual-dom/h`' , ( t ) => {
196199 const baseline = doc . replace ( / c o l o r : r e d ; / , 'color: red;' )
200+ /** @type {ReturnType<v> } */
201+ // @ts -expect-error Vue is too strict.
197202 const actual = toH ( v , hast )
198203 const expected = v ( 'div' , { key : 'h-1' } , [
199204 v (
200205 'h1' ,
201206 {
202207 key : 'h-2' ,
203- // @ts -ignore Works fine.
208+ // @ts -expect-error Works fine.
204209 attributes : { id : 'a' , class : 'b c' , hidden : true , height : 2 }
205210 } ,
206211 [
@@ -521,42 +526,42 @@ test('hast-to-hyperscript', (t) => {
521526
522527 t . test ( 'should support keys' , ( t ) => {
523528 t . equal (
524- // @ts -ignore Types are wrong.
529+ // @ts -expect-error Types are wrong.
525530 toH ( h , u ( 'element' , { tagName : 'div' } , [ ] ) ) . key ,
526531 undefined ,
527532 'should not patch `keys` normally'
528533 )
529534
530535 t . equal (
531- // @ts -ignore Types are wrong.
536+ // @ts -expect-error Types are wrong.
532537 toH ( h , u ( 'element' , { tagName : 'div' } , [ ] ) , 'prefix-' ) . key ,
533538 'prefix-1' ,
534539 'should patch `keys` when given'
535540 )
536541
537542 t . equal (
538- // @ts -ignore Types are wrong.
543+ // @ts -expect-error Types are wrong.
539544 toH ( h , u ( 'element' , { tagName : 'div' } , [ ] ) , true ) . key ,
540545 'h-1' ,
541546 'should patch `keys` when `true`'
542547 )
543548
544549 t . equal (
545- // @ts -ignore Types are wrong.
550+ // @ts -expect-error Types are wrong.
546551 toH ( h , u ( 'element' , { tagName : 'div' } , [ ] ) , false ) . key ,
547552 undefined ,
548553 'should not patch `keys` when `false`'
549554 )
550555
551556 t . equal (
552- // @ts -ignore Types are wrong.
557+ // @ts -expect-error Types are wrong.
558+ // type-coverage:ignore-next-line
553559 toH ( v , u ( 'element' , { tagName : 'div' } , [ ] ) ) . key ,
554560 'h-1' ,
555561 'should patch `keys` on vdom'
556562 )
557563
558564 t . equal (
559- // @ts -ignore Types are wrong.
560565 toH ( r , u ( 'element' , { tagName : 'div' } , [ ] ) ) . key ,
561566 'h-1' ,
562567 'should patch `keys` on react'
@@ -569,6 +574,7 @@ test('hast-to-hyperscript', (t) => {
569574 t . deepEqual (
570575 vToString (
571576 toH (
577+ // @ts -expect-error Vue is too strict.
572578 v ,
573579 u ( 'element' , { tagName : 'div' , properties : { style : 'color:red' } } , [ ] )
574580 )
@@ -581,7 +587,7 @@ test('hast-to-hyperscript', (t) => {
581587 toH (
582588 h ,
583589 u ( 'element' , { tagName : 'div' , properties : { style : 'color: red' } } , [ ] )
584- // @ts -ignore Types are wrong.
590+ // @ts -expect-error Types are wrong.
585591 ) . outerHTML ,
586592 '<div style="color:red;"></div>' ,
587593 'hyperscript: should parse a style declaration'
@@ -670,18 +676,24 @@ test('hast-to-hyperscript', (t) => {
670676
671677 t . test ( 'should support space' , ( t ) => {
672678 t . equal (
679+ // @ts -expect-error Vue is too strict.
680+ // type-coverage:ignore-next-line
673681 toH ( v , u ( 'element' , { tagName : 'div' } , [ ] ) ) . namespace ,
674682 null ,
675683 'should start in HTML'
676684 )
677685
678686 t . equal (
687+ // @ts -expect-error Vue is too strict.
688+ // type-coverage:ignore-next-line
679689 toH ( v , u ( 'element' , { tagName : 'div' } , [ ] ) , { space : 'svg' } ) . namespace ,
680690 ns . svg ,
681691 'should support `space: "svg"`'
682692 )
683693
684694 t . equal (
695+ // @ts -expect-error Vue is too strict.
696+ // type-coverage:ignore-next-line
685697 toH ( v , u ( 'element' , { tagName : 'svg' } , [ ] ) ) . namespace ,
686698 ns . svg ,
687699 'should infer `space: "svg"`'
@@ -698,7 +710,7 @@ test('hast-to-hyperscript', (t) => {
698710 const expected = h ( 'h1#a' )
699711 const doc = '<h1 id="a"></h1>'
700712
701- // @ts -ignore seems to exist fine 🤷♂️
713+ // @ts -expect-error seems to exist fine 🤷♂️
702714 t . deepEqual ( html ( actual . outerHTML ) , html ( doc ) , 'equal output' )
703715 t . deepEqual ( html ( expected . outerHTML ) , html ( doc ) , 'equal output baseline' )
704716 t . end ( )
@@ -709,7 +721,7 @@ test('hast-to-hyperscript', (t) => {
709721 const expected = h ( 'div' )
710722 const doc = '<div></div>'
711723
712- // @ts -ignore Types are wrong.
724+ // @ts -expect-error Types are wrong.
713725 t . deepEqual ( html ( actual . outerHTML ) , html ( doc ) , 'equal output' )
714726 t . deepEqual ( html ( expected . outerHTML ) , html ( doc ) , 'equal output baseline' )
715727 t . end ( )
@@ -720,7 +732,7 @@ test('hast-to-hyperscript', (t) => {
720732 const expected = h ( 'div' , 'Alpha' )
721733 const doc = '<div>Alpha</div>'
722734
723- // @ts -ignore Types are wrong.
735+ // @ts -expect-error Types are wrong.
724736 t . deepEqual ( html ( actual . outerHTML ) , html ( doc ) , 'equal output' )
725737 t . deepEqual ( html ( expected . outerHTML ) , html ( doc ) , 'equal output baseline' )
726738 t . end ( )
@@ -737,7 +749,7 @@ test('hast-to-hyperscript', (t) => {
737749 const expected = h ( 'div' , [ h ( 'h1' , 'Alpha' ) , h ( 'p' , 'Bravo' ) ] )
738750 const doc = '<div><h1>Alpha</h1><p>Bravo</p></div>'
739751
740- // @ts -ignore Types are wrong.
752+ // @ts -expect-error Types are wrong.
741753 t . deepEqual ( html ( actual . outerHTML ) , html ( doc ) , 'equal output' )
742754 t . deepEqual ( html ( expected . outerHTML ) , html ( doc ) , 'equal output baseline' )
743755 t . end ( )
@@ -803,7 +815,7 @@ test('hast-to-hyperscript', (t) => {
803815 * @returns {HastRoot }
804816 */
805817function html ( doc ) {
806- // @ts -ignore it’s a root!
818+ // @ts -expect-error it’s a root!
807819 return processor . parse ( doc )
808820}
809821
0 commit comments