Skip to content

Commit

Permalink
Provide TypeScript types for the public API.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Jan 18, 2019
1 parent a854f89 commit 03b3f88
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export type OptimisticWrapperFunction<
T = (...args: any[]) => any,
> = T & {
// The .dirty(...) method of an optimistic function takes exactly the
// same parameter types as the original function.
dirty: T;
};

export type OptimisticWrapOptions = {
max?: number;
disposable?: boolean;
makeCacheKey?(...args: any[]): any;
};

export declare function defaultMakeCacheKey(...args: any[]): object;

export declare function wrap<T>(
originalFunction: T,
options?: OptimisticWrapOptions,
): OptimisticWrapperFunction<T>;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"memoization"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"license": "MIT",
"homepage": "https://github.com/benjamn/optimism#readme",
"repository": {
Expand Down

0 comments on commit 03b3f88

Please sign in to comment.