From a558be114be1b607a1063e1434f71b0f49a4584a Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Wed, 12 Dec 2018 01:57:56 +0100 Subject: [PATCH] Add types for ps-list --- types/ps-list/index.d.ts | 24 ++++++++++++++++++++++++ types/ps-list/ps-list-tests.ts | 13 +++++++++++++ types/ps-list/tsconfig.json | 23 +++++++++++++++++++++++ types/ps-list/tslint.json | 1 + 4 files changed, 61 insertions(+) create mode 100644 types/ps-list/index.d.ts create mode 100644 types/ps-list/ps-list-tests.ts create mode 100644 types/ps-list/tsconfig.json create mode 100644 types/ps-list/tslint.json diff --git a/types/ps-list/index.d.ts b/types/ps-list/index.d.ts new file mode 100644 index 0000000000..2ace498667 --- /dev/null +++ b/types/ps-list/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for ps-list 6.0 +// Project: https://github.com/sindresorhus/ps-list#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export = psList; + +declare function psList(options?: psList.Options): Promise; + +declare namespace psList { + interface Options { + all?: boolean; + } + + interface ProcessDescriptor { + pid: number; + name: string; + ppid: number; + cmd?: string; + cpu?: number; + memory?: number; + } +} diff --git a/types/ps-list/ps-list-tests.ts b/types/ps-list/ps-list-tests.ts new file mode 100644 index 0000000000..17ecffe4ff --- /dev/null +++ b/types/ps-list/ps-list-tests.ts @@ -0,0 +1,13 @@ +import psList = require('ps-list'); + +(async () => { + const processes: psList.ProcessDescriptor[] = await psList(); + psList({ all: false }); + + processes[0].pid; // $ExpectType number + processes[0].name; // $ExpectType string + processes[0].ppid; // $ExpectType number + processes[0].cmd; // $ExpectType string | undefined + processes[0].cpu; // $ExpectType number | undefined + processes[0].memory; // $ExpectType number | undefined +})(); diff --git a/types/ps-list/tsconfig.json b/types/ps-list/tsconfig.json new file mode 100644 index 0000000000..4138547b6c --- /dev/null +++ b/types/ps-list/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ps-list-tests.ts" + ] +} diff --git a/types/ps-list/tslint.json b/types/ps-list/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ps-list/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }