From f8d259f70be796b8d35791f736f456b66e9fdd50 Mon Sep 17 00:00:00 2001 From: Miloslav Nenadal Date: Fri, 10 Nov 2017 14:59:14 +0100 Subject: [PATCH 1/2] [express-cluster]: Add types --- .../express-cluster/express-cluster-tests.ts | 6 +++++ types/express-cluster/index.d.ts | 26 +++++++++++++++++++ types/express-cluster/tsconfig.json | 22 ++++++++++++++++ types/express-cluster/tslint.json | 1 + 4 files changed, 55 insertions(+) create mode 100644 types/express-cluster/express-cluster-tests.ts create mode 100644 types/express-cluster/index.d.ts create mode 100644 types/express-cluster/tsconfig.json create mode 100644 types/express-cluster/tslint.json diff --git a/types/express-cluster/express-cluster-tests.ts b/types/express-cluster/express-cluster-tests.ts new file mode 100644 index 0000000000..1a530a01c2 --- /dev/null +++ b/types/express-cluster/express-cluster-tests.ts @@ -0,0 +1,6 @@ +import * as cluster from 'express-cluster'; + +() => { + cluster(worker => {}, {count: 5}); + cluster({count: 5}, worker => {}); +}; diff --git a/types/express-cluster/index.d.ts b/types/express-cluster/index.d.ts new file mode 100644 index 0000000000..a89aafc724 --- /dev/null +++ b/types/express-cluster/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for express-cluster 0.0 +// Project: https://github.com/Flipboard/express-cluster +// Definitions by: Miloslav Nenadál +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as cluster from 'cluster'; + +interface Config { + count?: number; + respawn?: boolean; + verbose?: boolean; + workerListener?(): void; + outputStream?: NodeJS.WritableStream; +} + +type WorkerFunction = (worker: cluster.Worker) => void; + +interface Cluster { + (fn: WorkerFunction, config: Config): void; + (config: Config, fn: WorkerFunction): void; +} + +declare const c: Cluster; +export = c; diff --git a/types/express-cluster/tsconfig.json b/types/express-cluster/tsconfig.json new file mode 100644 index 0000000000..26563cb1b6 --- /dev/null +++ b/types/express-cluster/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-cluster-tests.ts" + ] +} diff --git a/types/express-cluster/tslint.json b/types/express-cluster/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/express-cluster/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 6d8509d114d03dd8b42d5a7f5ccf020db8ea0fed Mon Sep 17 00:00:00 2001 From: Miloslav Nenadal Date: Mon, 13 Nov 2017 17:46:47 +0100 Subject: [PATCH 2/2] [express-cluster]: Fixes --- types/express-cluster/express-cluster-tests.ts | 2 +- types/express-cluster/index.d.ts | 2 +- types/express-cluster/tsconfig.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/types/express-cluster/express-cluster-tests.ts b/types/express-cluster/express-cluster-tests.ts index 1a530a01c2..4eb096ffd6 100644 --- a/types/express-cluster/express-cluster-tests.ts +++ b/types/express-cluster/express-cluster-tests.ts @@ -1,4 +1,4 @@ -import * as cluster from 'express-cluster'; +import cluster = require('express-cluster'); () => { cluster(worker => {}, {count: 5}); diff --git a/types/express-cluster/index.d.ts b/types/express-cluster/index.d.ts index a89aafc724..bee845d02e 100644 --- a/types/express-cluster/index.d.ts +++ b/types/express-cluster/index.d.ts @@ -5,7 +5,7 @@ /// -import * as cluster from 'cluster'; +import cluster = require('cluster'); interface Config { count?: number; diff --git a/types/express-cluster/tsconfig.json b/types/express-cluster/tsconfig.json index 26563cb1b6..5d27d3ec2e 100644 --- a/types/express-cluster/tsconfig.json +++ b/types/express-cluster/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +20,4 @@ "index.d.ts", "express-cluster-tests.ts" ] -} +} \ No newline at end of file