Add typings for is-callable (#27859)

* [@types/is-callable] Add type definition

* [@types/is-callable] Remove optional quantifier from parameter
This commit is contained in:
Daniel
2018-08-03 15:28:50 -07:00
committed by Sheetal Nandi
parent dfccb836de
commit 5d2acd7ea2
4 changed files with 58 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for is-callable 1.1
// Project: https://github.com/ljharb/is-callable
// Definitions by: Daniel <https://github.com/nieltg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function isCallable(val: any): val is (...args: any[]) => any;
export = isCallable;
+26
View File
@@ -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);
}
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }