Skip to content

Commit 5c204e2

Browse files
committed
Refactor types to use ConstructNameMap interface
1 parent a69238d commit 5c204e2

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules/
44
*.d.ts
55
*.log
66
yarn.lock
7+
!/index.d.ts

index.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from './lib/index.js'
2+
3+
declare module 'mdast-util-to-markdown' {
4+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
5+
interface ConstructNameMap {
6+
/**
7+
* Footnote reference.
8+
*
9+
* ```markdown
10+
* > | A[^b].
11+
* ^^^^
12+
* ```
13+
*/
14+
footnoteReference: 'footnoteReference'
15+
16+
/**
17+
* Footnote definition.
18+
*
19+
* ```markdown
20+
* > | [^a]: B.
21+
* ^^^^^^^^
22+
* ```
23+
*/
24+
footnoteDefinition: 'footnoteDefinition'
25+
}
26+
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// Note: extra types exported from `index.d.ts`.
12
export {gfmFootnoteFromMarkdown, gfmFootnoteToMarkdown} from './lib/index.js'

lib/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ export function gfmFootnoteToMarkdown() {
136136
function footnoteReference(node, _, context, safeOptions) {
137137
const tracker = track(safeOptions)
138138
let value = tracker.move('[^')
139-
// @ts-expect-error: use map.
140139
const exit = context.enter('footnoteReference')
141140
const subexit = context.enter('reference')
142141
value += tracker.move(
@@ -164,7 +163,6 @@ export function gfmFootnoteToMarkdown() {
164163
function footnoteDefinition(node, _, context, safeOptions) {
165164
const tracker = track(safeOptions)
166165
let value = tracker.move('[^')
167-
// @ts-expect-error: use map.
168166
const exit = context.enter('footnoteDefinition')
169167
const subexit = context.enter('label')
170168
value += tracker.move(

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["**/*.js"],
2+
"include": ["**/*.js", "index.d.ts"],
33
"exclude": ["coverage/", "node_modules/"],
44
"compilerOptions": {
55
"checkJs": true,

0 commit comments

Comments
 (0)