diff --git a/package.json b/package.json index c0081ba..4543cdd 100644 --- a/package.json +++ b/package.json @@ -25,11 +25,14 @@ "contributors": [ "Titus Wormer (https://wooorm.com)" ], + "types": "types/index.d.ts", "files": [ + "types/index.d.ts", "index.js" ], "dependencies": {}, "devDependencies": { + "dtslint": "^3.0.0", "nyc": "^15.0.0", "prettier": "^2.0.0", "rehype-format": "^3.0.0", @@ -49,7 +52,8 @@ "format": "remark . -qfo && prettier . --write && xo --fix", "test-api": "node test", "test-coverage": "nyc --reporter lcov tape test/index.js", - "test": "npm run format && npm run test-coverage" + "test-types": "dtslint types", + "test": "npm run format && npm run test-coverage && npm run test-types" }, "nyc": { "check-coverage": true, diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..080b9a9 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,20 @@ +// TypeScript Version: 3.4 + +import {Plugin} from 'unified' + +declare namespace remarkFootnotes { + type Footnotes = Plugin<[RemarkFootnotesOptions?]> + + interface RemarkFootnotesOptions { + /** + * Whether to support `^[inline notes]` + * + * @defaultValue false + */ + inlineNotes?: boolean + } +} + +declare const remarkFootnotes: remarkFootnotes.Footnotes + +export = remarkFootnotes diff --git a/types/remark-footnotes-tests.ts b/types/remark-footnotes-tests.ts new file mode 100644 index 0000000..9541524 --- /dev/null +++ b/types/remark-footnotes-tests.ts @@ -0,0 +1,6 @@ +import unified = require('unified') +import footnotes = require('remark-footnotes') + +unified().use(footnotes) +unified().use(footnotes, {}) +unified().use(footnotes, {inlineNotes: true}) diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 0000000..cf558db --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "lib": ["es2015"], + "strict": true, + "baseUrl": ".", + "paths": { + "remark-footnotes": ["index.d.ts"] + } + } +} diff --git a/types/tslint.json b/types/tslint.json new file mode 100644 index 0000000..70c4494 --- /dev/null +++ b/types/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "whitespace": false + } +}