Add types for npm-list-author-packages

This commit is contained in:
Florian Keller
2019-02-23 12:29:47 +01:00
parent 8816e2e88c
commit 29cf216fe9
4 changed files with 67 additions and 0 deletions

View File

@@ -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 <https://github.com/ffflorian>
// 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;

View File

@@ -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();

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }