Skip to content

Commit 2bcc6fc

Browse files
committed
Refactor types to use CompileData interface
1 parent 52d1b84 commit 2bcc6fc

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

index.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ export type {Options} from './lib/index.js'
22

33
export {gfmTableFromMarkdown, gfmTableToMarkdown} from './lib/index.js'
44

5+
// Add custom data tracked to turn markdown into a tree.
6+
declare module 'mdast-util-from-markdown' {
7+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
8+
interface CompileData {
9+
/**
10+
* Whether we’re currently in a table.
11+
*/
12+
inTable?: boolean | undefined
13+
}
14+
}
15+
516
// Add custom data tracked to turn a syntax tree into markdown.
617
declare module 'mdast-util-to-markdown' {
718
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions

lib/index.js

-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ function enterTable(token) {
5656
},
5757
token
5858
)
59-
// @ts-expect-error: to do: map.
6059
this.setData('inTable', true)
6160
}
6261

@@ -66,7 +65,6 @@ function enterTable(token) {
6665
*/
6766
function exitTable(token) {
6867
this.exit(token)
69-
// @ts-expect-error: to do: map.
7068
this.setData('inTable')
7169
}
7270

@@ -103,7 +101,6 @@ function enterCell(token) {
103101
function exitCodeText(token) {
104102
let value = this.resume()
105103

106-
// @ts-expect-error: to do: map.
107104
if (this.getData('inTable')) {
108105
value = value.replace(/\\([\\|])/g, replace)
109106
}

0 commit comments

Comments
 (0)