diff --git a/types/github-slugger/github-slugger-tests.ts b/types/github-slugger/github-slugger-tests.ts new file mode 100644 index 0000000000..53ea9fcd77 --- /dev/null +++ b/types/github-slugger/github-slugger-tests.ts @@ -0,0 +1,26 @@ +import GithubSlugger = require('github-slugger'); + +const slugger = new GithubSlugger(); +const slug = GithubSlugger.slug; + +slugger.slug('foo'); // $ExpectType string +// returns 'foo' + +slugger.slug('foo'); // $ExpectType string +// returns 'foo-1' + +slugger.slug('bar'); // $ExpectType string +// returns 'bar' + +slugger.slug('foo'); // $ExpectType string +// returns 'foo-2' + +slugger.reset(); // $ExpectType void + +slugger.slug('foo'); // $ExpectType string +// returns 'foo' +slug('foo bar baz'); // $ExpectType string +// returns 'foo-bar-baz' + +slug('foo bar baz'); // $ExpectType string +// returns the same slug 'foo-bar-baz' because it does not keep track diff --git a/types/github-slugger/index.d.ts b/types/github-slugger/index.d.ts new file mode 100644 index 0000000000..3313c8a0e9 --- /dev/null +++ b/types/github-slugger/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for github-slugger 1.3 +// Project: https://github.com/Flet/github-slugger +// Definitions by: Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Generate a slug just like GitHub does for markdown headings. + * It also ensures slugs are unique in the same way GitHub does it. The overall goal of this package is to emulate the way GitHub handles generating markdown heading anchors as close as possible + */ +declare class BananaSlug { + /** + * + * @param value string of text to slugify + * @param [maintainCase=false] Keep the current case, otherwise make all lowercase + */ + static slug(value: string | unknown, maintainCase?: boolean): string; + + /** + * + * @param value string of text to slugify + * @param [maintainCase=false] Keep the current case, otherwise make all lowercase + */ + slug(value: string, maintainCase?: boolean): string; + /** + * Forget all previous slugs + */ + reset(): void; +} + +export = BananaSlug; diff --git a/types/github-slugger/tsconfig.json b/types/github-slugger/tsconfig.json new file mode 100644 index 0000000000..fd45612dbf --- /dev/null +++ b/types/github-slugger/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "github-slugger-tests.ts" + ] +} diff --git a/types/github-slugger/tslint.json b/types/github-slugger/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/github-slugger/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }