Skip to content

Commit a909311

Browse files
types: add typescript typings for mdast-util-to-string
1 parent b706cdd commit a909311

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
"Titus Wormer <[email protected]> (https://wooorm.com)"
2626
],
2727
"files": [
28-
"index.js"
28+
"index.js",
29+
"types/index.d.ts"
2930
],
30-
"dependencies": {},
31+
"types": "types/index.d.ts",
3132
"devDependencies": {
3233
"browserify": "^17.0.0",
34+
"dtslint": "^4.0.0",
3335
"nyc": "^15.0.0",
3436
"prettier": "^2.0.0",
3537
"remark-cli": "^9.0.0",
@@ -45,7 +47,8 @@
4547
"build": "npm run build-bundle && npm run build-mangle",
4648
"test-api": "node test",
4749
"test-coverage": "nyc --reporter lcov tape test.js",
48-
"test": "npm run format && npm run build && npm run test-coverage"
50+
"test-types": "dtslint types",
51+
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
4952
},
5053
"prettier": {
5154
"tabWidth": 2,

types/index.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Minimum TypeScript Version: 3.0
2+
import {Node} from 'unist'
3+
4+
declare namespace mdastToString {}
5+
6+
declare function mdastToString(node: Node): string
7+
8+
export = mdastToString

types/test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import mdastUtilToString = require('mdast-util-to-string')
2+
3+
mdastUtilToString() // $ExpectError
4+
mdastUtilToString({type: 'root'}) // $ExpectType string

types/tsconfig.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "node",
4+
"lib": [
5+
"ES5"
6+
],
7+
"strict": true,
8+
"baseUrl": ".",
9+
"paths": {
10+
"mdast-util-to-string": [
11+
"./index.d.ts"
12+
]
13+
}
14+
}
15+
}

types/tslint.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "dtslint/dtslint.json",
3+
"rules": {
4+
"semicolon": false,
5+
"whitespace": false
6+
}
7+
}

0 commit comments

Comments
 (0)