Skip to content

Commit 67cca5a

Browse files
Add types
Closes GH-5. Reviewed-by: Remco Haszing <remcohaszing@gmail.com> Reviewed-by: Merlijn Vos <merlijn@soverin.net> Reviewed-by: Titus Wormer <tituswormer@gmail.com>
1 parent b706cdd commit 67cca5a

File tree

5 files changed

+43
-4
lines changed

5 files changed

+43
-4
lines changed

Diff for: package.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
"Titus Wormer <tituswormer@gmail.com> (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,
@@ -59,7 +62,8 @@
5962
"prettier": true,
6063
"esnext": false,
6164
"ignore": [
62-
"mdast-util-to-string.js"
65+
"mdast-util-to-string.js",
66+
"types/test.ts"
6367
]
6468
},
6569
"nyc": {

Diff for: 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 | Node[]): string
7+
8+
export = mdastToString

Diff for: types/test.ts

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

Diff for: 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+
}

Diff for: 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)