diff --git a/types/npm-list-author-packages/index.d.ts b/types/npm-list-author-packages/index.d.ts new file mode 100644 index 0000000000..d482c7f514 --- /dev/null +++ b/types/npm-list-author-packages/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for npm-list-author-packages 2.0 +// Project: https://github.com/kgryte/npm-list-author-packages#readme +// Definitions by: Florian Keller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace list { + interface Options { + /** registry port. Default: 443 (HTTPS) or 80 (HTTP). */ + port?: 443 | 80; + /** registry protocol. Default: 'https'. */ + protocol?: 'http' | 'https'; + /** registry. Default: 'registry.npmjs.org'. */ + registry?: string; + /** author username (required). */ + username: string; + } + + type Callback = (error: Error | null, data: string[]) => void; + + function factory(opts: Options, callback: Callback): () => void; +} + +declare function list(opts: list.Options, callback: list.Callback): void; + +export = list; diff --git a/types/npm-list-author-packages/npm-list-author-packages-tests.ts b/types/npm-list-author-packages/npm-list-author-packages-tests.ts new file mode 100644 index 0000000000..4f2d08d778 --- /dev/null +++ b/types/npm-list-author-packages/npm-list-author-packages-tests.ts @@ -0,0 +1,18 @@ +import list = require('npm-list-author-packages'); + +const opts: list.Options = { + port: 80, + protocol: 'http', + registry: 'my.favorite.npm/registry', + username: 'kgryte', +}; + +list(opts, (error, data) => { + data; // $ExpectType string[] +}); + +const get = list.factory({ username: 'kgryte' }, (error, data) => { + data; // $ExpectType string[] +}); + +get(); diff --git a/types/npm-list-author-packages/tsconfig.json b/types/npm-list-author-packages/tsconfig.json new file mode 100644 index 0000000000..e05e42ead0 --- /dev/null +++ b/types/npm-list-author-packages/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", + "npm-list-author-packages-tests.ts" + ] +} diff --git a/types/npm-list-author-packages/tslint.json b/types/npm-list-author-packages/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-list-author-packages/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }