[get-func-name] Add types (#31774)

This commit is contained in:
Dimitri Benin
2018-12-31 16:18:54 +00:00
committed by Wesley Wigham
parent 236449ab1d
commit e713f37fd4
4 changed files with 44 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import getFuncName = require('get-func-name');
const unknownFunction = function myCoolFunction(word: string) {
return word + 'is cool';
};
const anonymousFunction = (() => {
return () => {};
})();
getFuncName(unknownFunction); // $ExpectType string
getFuncName(anonymousFunction); // $ExpectType string

8
types/get-func-name/index.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
// Type definitions for get-func-name 2.0
// Project: https://github.com/chaijs/get-func-name#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = getFuncName;
declare function getFuncName(fn: Function): string; // tslint:disable-line:ban-types

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",
"get-func-name-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }