mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 14:38:20 +08:00
Fix export for debounce, add tslint.json (#16035)
* Fix export for debounce, add tslint.json * Add clear method
This commit is contained in:
@@ -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();
|
||||
|
||||
9
types/debounce/index.d.ts
vendored
9
types/debounce/index.d.ts
vendored
@@ -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;
|
||||
|
||||
6
types/debounce/tslint.json
Normal file
6
types/debounce/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"ban-types": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user