mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
[memoize-one] keep v3 typings
This commit is contained in:
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// Type definitions for memoize-one 3.1
|
||||
// Project: https://github.com/alexreardon/memoize-one#readme
|
||||
// Definitions by: Karol Majewski <https://github.com/karol-majewski>, Frank Li <https://github.com/franklixuefei>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function memoizeOne<T extends (...args: any[]) => any>(resultFn: T, isEqual?: EqualityFn): T;
|
||||
export type EqualityFn = (a: any, b: any) => boolean;
|
||||
|
||||
export default memoizeOne;
|
||||
@@ -0,0 +1,33 @@
|
||||
import memoizeOne, { EqualityFn } from 'memoize-one';
|
||||
|
||||
declare function add(a: number, b: number): number ;
|
||||
declare function lousyEqualityFn(a: any, b: any): boolean;
|
||||
declare function strictEqualityFn<T>(a: T, b: T): boolean;
|
||||
|
||||
/**
|
||||
* Accepts a second argument.
|
||||
*/
|
||||
memoizeOne(add); // $ExpectType (a: number, b: number) => number
|
||||
memoizeOne(add, lousyEqualityFn); // $ExpectType (a: number, b: number) => number
|
||||
memoizeOne(add, strictEqualityFn); // $ExpectType (a: number, b: number) => number
|
||||
|
||||
/**
|
||||
* The second argument can be, but doesn't have to be strictly typed.
|
||||
*/
|
||||
memoizeOne(add, (a, b) => a === b); // $ExpectType (a: number, b: number) => number
|
||||
memoizeOne(add, (a: string, b: string) => a === b); // $ExpectType (a: number, b: number) => number
|
||||
|
||||
/**
|
||||
* Function passed as the second argument accepts exactly two arguments.
|
||||
*/
|
||||
memoizeOne(add, (a: number, b: number, c: number) => a === b || c); // $ExpectError
|
||||
|
||||
/**
|
||||
* Function passed as the second argument returns a boolean.
|
||||
*/
|
||||
memoizeOne(add, (a: string, b: string) => 0); // $ExpectError
|
||||
|
||||
/**
|
||||
* The `EqualityFn` type is publicly accessible.
|
||||
*/
|
||||
const simpleIsEqual: EqualityFn = (x: number, y: number): boolean => (x === y);
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../../",
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
],
|
||||
"types": [],
|
||||
"paths": {
|
||||
"memoize-one": [ "memoize-one/v3" ]
|
||||
},
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"memoize-one-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user