From f5f3135108f26bd097de45b52c9c9a9a166cc561 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Mon, 12 Feb 2018 16:30:21 +0100 Subject: [PATCH 1/2] Add types for npm-packlist --- types/npm-packlist/index.d.ts | 16 ++++++++++++++++ types/npm-packlist/npm-packlist-tests.ts | 14 ++++++++++++++ types/npm-packlist/tsconfig.json | 24 ++++++++++++++++++++++++ types/npm-packlist/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/npm-packlist/index.d.ts create mode 100644 types/npm-packlist/npm-packlist-tests.ts create mode 100644 types/npm-packlist/tsconfig.json create mode 100644 types/npm-packlist/tslint.json diff --git a/types/npm-packlist/index.d.ts b/types/npm-packlist/index.d.ts new file mode 100644 index 0000000000..88a0f82fa4 --- /dev/null +++ b/types/npm-packlist/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for npm-packlist 1.1 +// Project: https://www.npmjs.com/package/npm-packlist +// Definitions by: Klaus Meinhardt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +declare function packlist(options?: packlist.Options): Promise; +declare function packlist(options: packlist.Options | undefined, callback: (result: string[]) => T): Promise; +declare namespace packlist { + interface Options { + /** Directory to walk recusively. Defaults to `process.cwd()`. */ + path?: string; + } + function sync(options?: Options): string[]; +} +export = packlist; diff --git a/types/npm-packlist/npm-packlist-tests.ts b/types/npm-packlist/npm-packlist-tests.ts new file mode 100644 index 0000000000..162a7d86f5 --- /dev/null +++ b/types/npm-packlist/npm-packlist-tests.ts @@ -0,0 +1,14 @@ +import packlist = require('npm-packlist'); + +let result: string[] = packlist.sync(); +result = packlist.sync({}); +result = packlist.sync({path: 'foo'}); + +(async () => { + result = await packlist(); + result = await packlist({}); + result = await packlist({path: 'foo'}); + + packlist(undefined, (r) => result = r); + packlist({path: 'foo'}, (r) => result = r); +})(); diff --git a/types/npm-packlist/tsconfig.json b/types/npm-packlist/tsconfig.json new file mode 100644 index 0000000000..29834afe3e --- /dev/null +++ b/types/npm-packlist/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "esModuleInterop": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "npm-packlist-tests.ts" + ] +} diff --git a/types/npm-packlist/tslint.json b/types/npm-packlist/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-packlist/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 320ff9a08dd1d2296294d2c7d5bdb8abba90c5a3 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Tue, 13 Feb 2018 09:08:43 +0100 Subject: [PATCH 2/2] fix link --- types/npm-packlist/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/npm-packlist/index.d.ts b/types/npm-packlist/index.d.ts index 88a0f82fa4..934d2f8967 100644 --- a/types/npm-packlist/index.d.ts +++ b/types/npm-packlist/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for npm-packlist 1.1 -// Project: https://www.npmjs.com/package/npm-packlist +// Project: https://github.com/npm/npm-packlist // Definitions by: Klaus Meinhardt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1