From 45f9d409646e5dba28e28e0f9a8848672775aa8d Mon Sep 17 00:00:00 2001 From: Evangelos Zotos Date: Sun, 20 Jan 2019 02:57:48 +0100 Subject: [PATCH 1/4] Adds type definitions for the npm module "is-function" --- types/is-function/index.d.ts | 8 ++++++++ types/is-function/is-function-tests.ts | 9 +++++++++ types/is-function/tsconfig.json | 16 ++++++++++++++++ types/is-function/tslint.json | 1 + 4 files changed, 34 insertions(+) create mode 100644 types/is-function/index.d.ts create mode 100644 types/is-function/is-function-tests.ts create mode 100644 types/is-function/tsconfig.json create mode 100644 types/is-function/tslint.json diff --git a/types/is-function/index.d.ts b/types/is-function/index.d.ts new file mode 100644 index 0000000000..96a13f0b34 --- /dev/null +++ b/types/is-function/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for is-function 1.0 +// Project: https://github.com/grncdr/js-is-function +// Definitions by: Evangelos Zotos +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function isFunction(fn: any): boolean; +declare namespace isFunction {} +export = isFunction; diff --git a/types/is-function/is-function-tests.ts b/types/is-function/is-function-tests.ts new file mode 100644 index 0000000000..a4f4215875 --- /dev/null +++ b/types/is-function/is-function-tests.ts @@ -0,0 +1,9 @@ +import * as isFunction from "is-function"; + +const a: boolean = isFunction("string"); +const b: boolean = isFunction(true); +const c: boolean = isFunction((a: number) => a * a); +const d: boolean = isFunction({ type: "number" }); +const e: boolean = isFunction(() => { + return "I am anounymous!"; +}); diff --git a/types/is-function/tsconfig.json b/types/is-function/tsconfig.json new file mode 100644 index 0000000000..ab7efbe2c7 --- /dev/null +++ b/types/is-function/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "is-function-tests.ts"] +} diff --git a/types/is-function/tslint.json b/types/is-function/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-function/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d754d3c6712d0c3d1a2179d2362d98160714a18e Mon Sep 17 00:00:00 2001 From: Evangelos Zotos Date: Mon, 21 Jan 2019 21:06:34 +0100 Subject: [PATCH 2/4] fixed namespace hack --- types/is-function/index.d.ts | 4 +--- types/is-function/is-function-tests.ts | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/types/is-function/index.d.ts b/types/is-function/index.d.ts index 96a13f0b34..8cde4b0493 100644 --- a/types/is-function/index.d.ts +++ b/types/is-function/index.d.ts @@ -3,6 +3,4 @@ // Definitions by: Evangelos Zotos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function isFunction(fn: any): boolean; -declare namespace isFunction {} -export = isFunction; +export default function isFunction(fn: any): boolean; diff --git a/types/is-function/is-function-tests.ts b/types/is-function/is-function-tests.ts index a4f4215875..f18cd7b132 100644 --- a/types/is-function/is-function-tests.ts +++ b/types/is-function/is-function-tests.ts @@ -1,8 +1,8 @@ -import * as isFunction from "is-function"; +import isFunction from "is-function"; const a: boolean = isFunction("string"); const b: boolean = isFunction(true); -const c: boolean = isFunction((a: number) => a * a); +const c: boolean = isFunction((x: number) => x * x); const d: boolean = isFunction({ type: "number" }); const e: boolean = isFunction(() => { return "I am anounymous!"; From 6ce7d0dab3e6fdb906122054fc39e454472cece4 Mon Sep 17 00:00:00 2001 From: Evangelos Zotos Date: Tue, 22 Jan 2019 23:47:14 +0100 Subject: [PATCH 3/4] removes the default export and return back to the initial proposal of "is-function" --- types/is-function/index.d.ts | 4 +++- types/is-function/is-function-tests.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/is-function/index.d.ts b/types/is-function/index.d.ts index 8cde4b0493..a979d606e3 100644 --- a/types/is-function/index.d.ts +++ b/types/is-function/index.d.ts @@ -3,4 +3,6 @@ // Definitions by: Evangelos Zotos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default function isFunction(fn: any): boolean; +export = isFunction; +declare function isFunction(fn: any): boolean; +declare namespace isFunction {} diff --git a/types/is-function/is-function-tests.ts b/types/is-function/is-function-tests.ts index f18cd7b132..26caa76988 100644 --- a/types/is-function/is-function-tests.ts +++ b/types/is-function/is-function-tests.ts @@ -1,4 +1,4 @@ -import isFunction from "is-function"; +import * as isFunction from "is-function"; const a: boolean = isFunction("string"); const b: boolean = isFunction(true); From c5d0ec05d8b75c6254024d1448f93534f7e86c25 Mon Sep 17 00:00:00 2001 From: Evangelos Zotos Date: Wed, 23 Jan 2019 21:27:45 +0100 Subject: [PATCH 4/4] uses import isFunction = require("is-function") style import --- types/is-function/index.d.ts | 1 - types/is-function/is-function-tests.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/is-function/index.d.ts b/types/is-function/index.d.ts index a979d606e3..841180173a 100644 --- a/types/is-function/index.d.ts +++ b/types/is-function/index.d.ts @@ -5,4 +5,3 @@ export = isFunction; declare function isFunction(fn: any): boolean; -declare namespace isFunction {} diff --git a/types/is-function/is-function-tests.ts b/types/is-function/is-function-tests.ts index 26caa76988..d88d529710 100644 --- a/types/is-function/is-function-tests.ts +++ b/types/is-function/is-function-tests.ts @@ -1,4 +1,4 @@ -import * as isFunction from "is-function"; +import isFunction = require("is-function"); const a: boolean = isFunction("string"); const b: boolean = isFunction(true);