diff --git a/types/is-callable/index.d.ts b/types/is-callable/index.d.ts new file mode 100644 index 0000000000..7e2c89f845 --- /dev/null +++ b/types/is-callable/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for is-callable 1.1 +// Project: https://github.com/ljharb/is-callable +// Definitions by: Daniel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function isCallable(val: any): val is (...args: any[]) => any; + +export = isCallable; diff --git a/types/is-callable/is-callable-tests.ts b/types/is-callable/is-callable-tests.ts new file mode 100644 index 0000000000..7ae8518ffd --- /dev/null +++ b/types/is-callable/is-callable-tests.ts @@ -0,0 +1,26 @@ +import isCallable = require("is-callable"); + +isCallable(undefined); +isCallable(null); +isCallable(false); +isCallable(true); +isCallable([]); +isCallable({}); +isCallable(/a/g); +isCallable(new RegExp("a", "g")); +isCallable(new Date()); +isCallable(42); +isCallable(NaN); +isCallable(Infinity); +isCallable("foo"); +isCallable(Object("foo")); + +function func1() {} +if (isCallable(func1)) { + func1(); +} + +const func2 = (x: number) => x * x; +if (isCallable(func2)) { + func2(0); +} diff --git a/types/is-callable/tsconfig.json b/types/is-callable/tsconfig.json new file mode 100644 index 0000000000..e1334095d7 --- /dev/null +++ b/types/is-callable/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", + "is-callable-tests.ts" + ] +} diff --git a/types/is-callable/tslint.json b/types/is-callable/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-callable/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }