Skip to content

Commit

Permalink
Add types
Browse files Browse the repository at this point in the history
Closes GH-5.

Reviewed-by: Remco Haszing <remcohaszing@gmail.com>
Reviewed-by: Merlijn Vos <merlijn@soverin.net>
Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
ChristianMurphy authored Nov 11, 2020
1 parent b706cdd commit 67cca5a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"files": [
"index.js"
"index.js",
"types/index.d.ts"
],
"dependencies": {},
"types": "types/index.d.ts",
"devDependencies": {
"browserify": "^17.0.0",
"dtslint": "^4.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
Expand All @@ -45,7 +47,8 @@
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"test-types": "dtslint types",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
},
"prettier": {
"tabWidth": 2,
Expand All @@ -59,7 +62,8 @@
"prettier": true,
"esnext": false,
"ignore": [
"mdast-util-to-string.js"
"mdast-util-to-string.js",
"types/test.ts"
]
},
"nyc": {
Expand Down
8 changes: 8 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Minimum TypeScript Version: 3.0
import {Node} from 'unist'

declare namespace mdastToString {}

declare function mdastToString(node: Node | Node[]): string

export = mdastToString
5 changes: 5 additions & 0 deletions types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as mdastUtilToString from 'mdast-util-to-string'

mdastUtilToString() // $ExpectError
mdastUtilToString({type: 'root'}) // $ExpectType string
mdastUtilToString([{type: 'root'}]) // $ExpectType string
15 changes: 15 additions & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"moduleResolution": "node",
"lib": [
"ES5"
],
"strict": true,
"baseUrl": ".",
"paths": {
"mdast-util-to-string": [
"./index.d.ts"
]
}
}
}
7 changes: 7 additions & 0 deletions types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"semicolon": false,
"whitespace": false
}
}

0 comments on commit 67cca5a

Please sign in to comment.