mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
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:
Vendored
+8
@@ -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;
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user