mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 06:10:06 +00:00
[underscore] Add generic type for memoize (#34994)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
f832cffd77
commit
353eb17ad6
2
types/underscore.string/index.d.ts
vendored
2
types/underscore.string/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/epeli/underscore.string
|
||||
// Definitions by: Ry Racherbaumer <https://github.com/rygine>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as _ from 'underscore';
|
||||
|
||||
|
||||
21
types/underscore/index.d.ts
vendored
21
types/underscore/index.d.ts
vendored
@@ -1,13 +1,14 @@
|
||||
// Type definitions for Underscore 1.8
|
||||
// Project: http://underscorejs.org/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>
|
||||
// Josh Baldwin <https://github.com/jbaldwin>
|
||||
// Christopher Currens <https://github.com/ccurrens>
|
||||
// Cassey Lottman <https://github.com/clottman>
|
||||
// Ard Timmerman <https://github.com/confususs>
|
||||
// Julian Gonggrijp <https://github.com/jgonggrijp>
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>,
|
||||
// Josh Baldwin <https://github.com/jbaldwin>,
|
||||
// Christopher Currens <https://github.com/ccurrens>,
|
||||
// Cassey Lottman <https://github.com/clottman>,
|
||||
// Ard Timmerman <https://github.com/confususs>,
|
||||
// Julian Gonggrijp <https://github.com/jgonggrijp>,
|
||||
// Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare var _: _.UnderscoreStatic;
|
||||
export = _;
|
||||
@@ -3447,9 +3448,9 @@ declare module _ {
|
||||
* @param hashFn Hash function for storing the result of `fn`.
|
||||
* @return Memoized version of `fn`.
|
||||
**/
|
||||
memoize(
|
||||
fn: Function,
|
||||
hashFn?: (...args: any[]) => string): Function;
|
||||
memoize<T = Function>(
|
||||
fn: T,
|
||||
hashFn?: (...args: any[]) => string): T;
|
||||
|
||||
/**
|
||||
* Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments,
|
||||
|
||||
@@ -285,6 +285,12 @@ var fibonacci = _.memoize(function (n) {
|
||||
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
||||
});
|
||||
|
||||
class MyClass {};
|
||||
|
||||
var classMemoized = _.memoize<MyClass>(function (classInstance) {
|
||||
return new classInstance();
|
||||
});
|
||||
|
||||
var log = _.bind(console.log, console);
|
||||
_.delay(log, 1000, 'logged later');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user