Fix export for debounce, add tslint.json (#16035)

* Fix export for debounce, add tslint.json

* Add clear method
This commit is contained in:
Karol Janyst
2017-04-21 23:29:22 +09:00
committed by Andy
parent 45db0d6087
commit 7290661a96
3 changed files with 16 additions and 11 deletions

View File

@@ -1,13 +1,15 @@
import debounce from "debounce";
import debounce = require("debounce");
const doThings = () => 1;
debounce(function(){ doThings(); })();
debounce(doThings)();
debounce(function(){ doThings(); }, 1000)();
debounce(doThings, 1000)();
debounce(function(a: string){ doThings(); }, 1000)("foo");
debounce((a: string) => doThings, 1000)("foo");
// Immediate true should return the value
const imm1: number = (debounce((x: number) => x * 2, 100, true))(2);
const clearable = debounce(doThings);
clearable.clear();

View File

@@ -1,10 +1,7 @@
// Type definitions for compose-function
// Type definitions for debounce 1.0
// Project: https://github.com/component/debounce
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Overload on boolean constants would allow us to narrow further,
// but it is not implemented for TypeScript yet
declare function f<A extends Function>(f: A, interval?: number, immediate?: boolean): A
export default f;
declare function debounce<A extends Function>(f: A, interval?: number, immediate?: boolean): A & { clear(): void; };
export = debounce;

View File

@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"ban-types": false
}
}