Skip to content

Commit 9b91bb1

Browse files
committed
Fix for changes in @types/unist
1 parent 15eba4f commit 9b91bb1

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
coverage/
22
node_modules/
33
.DS_Store
4-
*.d.ts
4+
index.d.ts
5+
test.d.ts
56
*.log
67
yarn.lock

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ function opener(matter) {
5252
/** @type {FromMarkdownHandle} */
5353
function close(token) {
5454
const data = this.resume()
55+
const node = /** @type {Literal} */ (this.exit(token))
5556
// Remove the initial and final eol.
56-
this.exit(token).value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, '')
57+
node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, '')
5758
}
5859

5960
/** @type {FromMarkdownHandle} */

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"xo": "^0.39.0"
5454
},
5555
"scripts": {
56-
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
56+
"build": "rimraf \"{index,test}.d.ts\" && tsc && type-coverage",
5757
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
5858
"test-api": "node --conditions development test.js",
5959
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --conditions development test.js",

test-types.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {Literal} from 'mdast'
2+
3+
interface TOML extends Literal {
4+
type: 'toml'
5+
}
6+
7+
interface JSON extends Literal {
8+
type: 'json'
9+
}
10+
11+
interface Custom extends Literal {
12+
type: 'custom'
13+
}
14+
15+
declare module 'mdast' {
16+
// To do: this should be `FrontmatterMap`, which doesn’t exist yet.
17+
interface BlockContentMap {
18+
toml: TOML
19+
custom: Custom
20+
json: JSON
21+
}
22+
}

test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @typedef {import('./test-types')} TOML
3+
*/
4+
15
import test from 'tape'
26
import {fromMarkdown} from 'mdast-util-from-markdown'
37
import {toMarkdown} from 'mdast-util-to-markdown'

0 commit comments

Comments
 (0)