Skip to content

Commit da1d73f

Browse files
committed
Fix for changes in @types/unist
1 parent 42174cc commit da1d73f

File tree

14 files changed

+21
-29
lines changed

14 files changed

+21
-29
lines changed

lib/handlers/code.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import {wrapText} from '../util/wrap-text.js'
1111

1212
const prefix = 'language-'
1313

14-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'pre'}>} */
1514
const pre = convertElement('pre')
16-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'code'}>} */
1715
const isCode = convertElement('code')
1816

1917
/**

lib/handlers/dl.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ import {convertElement} from 'hast-util-is-element'
1616
import {listItemsSpread} from '../util/list-items-spread.js'
1717
import {wrapListItems} from '../util/wrap-list-items.js'
1818

19-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'div'}>} */
2019
const div = convertElement('div')
21-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'dt'}>} */
2220
const dt = convertElement('dt')
23-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'dd'}>} */
2421
const dd = convertElement('dd')
2522

2623
/**
@@ -117,10 +114,10 @@ function handle(h, children) {
117114
}
118115

119116
return [
120-
// @ts-expect-error: `null` is fine.
121117
{
122118
type: 'list',
123119
ordered: false,
120+
// @ts-expect-error: `null` is fine.
124121
start: null,
125122
spread: listItemsSpread(nodes),
126123
children: nodes

lib/handlers/iframe.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export function iframe(h, node) {
2525
if (src && title) {
2626
return {
2727
type: 'link',
28-
// @ts-expect-error: `null` is fine.
2928
title: null,
3029
url: resolve(h, src),
3130
children: [{type: 'text', value: wrapText(h, title)}]

lib/handlers/input.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {own} from '../util/own.js'
1212
import {resolve} from '../util/resolve.js'
1313
import {wrapText} from '../util/wrap-text.js'
1414

15-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'datalist'}>} */
1615
const datalist = convertElement('datalist')
1716

1817
/**

lib/handlers/li.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import {convertElement} from 'hast-util-is-element'
99
import {shallow} from '../util/shallow.js'
1010
import {wrapChildren} from '../util/wrap-children.js'
1111

12-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'p'}>} */
1312
const p = convertElement('p')
14-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'input'}>} */
1513
const input = convertElement('input')
1614

1715
/**

lib/handlers/list.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {hasProperty} from 'hast-util-has-property'
88
import {listItemsSpread} from '../util/list-items-spread.js'
99
import {wrapListItems} from '../util/wrap-list-items.js'
1010

11-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'ol'}>} */
1211
const ol = convertElement('ol')
1312

1413
/**

lib/handlers/media.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import {all} from '../all.js'
1212
import {resolve} from '../util/resolve.js'
1313
import {wrapNeeded} from '../util/wrap.js'
1414

15-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'source'}>} */
1615
const source = convertElement('source')
17-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'video'}>} */
1816
const video = convertElement('video')
1917

2018
/**
@@ -34,6 +32,7 @@ export function media(h, node) {
3432
/** @type {ElementChild} */
3533
let child
3634

35+
// @ts-expect-error: assume valid content.
3736
visit({type: 'root', children: nodes}, 'link', findLink)
3837

3938
// If the content links to something, or if it’s not phrasing…
@@ -53,7 +52,6 @@ export function media(h, node) {
5352
// If there’s a poster defined on the video, create an image.
5453
if (poster) {
5554
nodes = [
56-
// @ts-expect-error: `null` is fine.
5755
{
5856
type: 'image',
5957
title: null,

lib/handlers/table.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import {convertElement} from 'hast-util-is-element'
1515
import {visit} from 'unist-util-visit'
1616
import {all} from '../all.js'
1717

18-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'thead'}>} */
1918
const thead = convertElement('thead')
20-
/** @type {import('unist-util-is').AssertPredicate<Element & {tagName: 'tr'}>} */
2119
const tr = convertElement('tr')
2220
const cell = convertElement(['th', 'td'])
2321

@@ -50,12 +48,7 @@ function inspect(node) {
5048
/** @type {import('unist-util-visit').Visitor<Element>} */
5149
function visitor(child) {
5250
// If there is a `thead`, assume there is a header row.
53-
if (thead(child)) {
54-
headless = false
55-
} else if (tr(child)) {
56-
rowIndex++
57-
cellIndex = 0
58-
} else if (cell(child)) {
51+
if (cell(child)) {
5952
if (!align[cellIndex]) {
6053
// @ts-expect-error: `props` are defined.
6154
align[cellIndex] = String(child.properties.align || '') || null
@@ -67,6 +60,11 @@ function inspect(node) {
6760
}
6861

6962
cellIndex++
63+
} else if (thead(child)) {
64+
headless = false
65+
} else if (tr(child)) {
66+
rowIndex++
67+
cellIndex = 0
7068
}
7169
}
7270
}

lib/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ export function toMdast(tree, options = {}) {
6666
const result = {type, ...properties}
6767

6868
if (typeof children === 'string') {
69+
// @ts-expect-error: Looks like a literal.
6970
result.value = children
7071
} else if (children) {
72+
// @ts-expect-error: Looks like a parent.
7173
result.children = children
7274
}
7375

@@ -142,6 +144,7 @@ export function toMdast(tree, options = {}) {
142144
const previous = parent.children[index - 1]
143145

144146
if (previous && previous.type === node.type) {
147+
// @ts-expect-error: Looks like a literal.
145148
previous.value += node.value
146149
parent.children.splice(index, 1)
147150

lib/one.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export function one(h, node, parent) {
4444
* @param {Node} node
4545
*/
4646
function unknown(h, node) {
47+
// @ts-expect-error: Looks like a literal.
4748
if (typeof node.value === 'string') {
49+
// @ts-expect-error: Looks like a literal.
4850
return h(node, 'text', wrapText(h, node.value))
4951
}
5052

0 commit comments

Comments
 (0)