Skip to content

Commit

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

Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
Reviewed-by: Junyoung Choi <fluke8259@gmail.com>
Reviewed-by: Titus Wormer <tituswormer@gmail.com>
  • Loading branch information
BarryThePenguin authored and wooorm committed Jan 19, 2020
1 parent 2385f87 commit 635ad84
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 4 deletions.
11 changes: 8 additions & 3 deletions package.json
Expand Up @@ -28,14 +28,18 @@
"Jonathan Haines <jonno.haines@gmail.com>",
"Robin Millette <robin@millette.info>"
],
"types": "types/index.d.ts",
"files": [
"types/index.d.ts",
"index.js"
],
"dependencies": {
"mdast-util-toc": "^4.0.0"
"@types/unist": "^2.0.3",
"mdast-util-toc": "^5.0.0"
},
"devDependencies": {
"browserify": "^16.0.0",
"dtslint": "^2.0.0",
"is-hidden": "^1.1.0",
"negate": "^1.0.0",
"nyc": "^14.0.0",
Expand All @@ -45,7 +49,7 @@
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"xo": "^0.24.0"
"xo": "^0.25.0"
},
"scripts": {
"format": "remark *.md -qfo && prettier --write \"**/*.js\" && xo --fix",
Expand All @@ -54,7 +58,8 @@
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test/index.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 Down
2 changes: 1 addition & 1 deletion test/index.js
Expand Up @@ -42,7 +42,7 @@ test('Fixtures', function(t) {

try {
config = JSON.parse(read(join(filepath, 'config.json')))
} catch (error) {
} catch (_) {
config = {}
}

Expand Down
19 changes: 19 additions & 0 deletions types/index.d.ts
@@ -0,0 +1,19 @@
// Minimum TypeScript Version: 3.2

import {Node} from 'unist'
import {TOCOptions} from 'mdast-util-toc'

declare namespace remarkToc {
type TOCSettings = Pick<TOCOptions, 'heading' | 'maxDepth' | 'tight' | 'skip'>;
}

/**
* Generate a Table of Contents.
*
* @param settings configuration for generating the table of contents
*/
declare function remarkToc(
settings?: remarkToc.TOCSettings
): (node: Node) => void

export = remarkToc
23 changes: 23 additions & 0 deletions types/remark-toc-tests.ts
@@ -0,0 +1,23 @@
import remark = require('remark')

import toc = require('remark-toc')

remark().use(toc)

remark().use(toc, {})

remark().use(toc, {
heading: 'heading'
})

remark().use(toc, {
maxDepth: 2
})

remark().use(toc, {
tight: true
})

remark().use(toc, {
skip: 'skip-heading'
})
10 changes: 10 additions & 0 deletions types/tsconfig.json
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"lib": ["es2015"],
"strict": true,
"baseUrl": ".",
"paths": {
"remark-toc": ["index.d.ts"]
}
}
}
7 changes: 7 additions & 0 deletions types/tslint.json
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"semicolon": false,
"whitespace": false
}
}

0 comments on commit 635ad84

Please sign in to comment.