-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
In the typings, the cache
is expecting an object that not includes a Create
method. It's correct? What's the right way to use it with Typescript?
export interface Cache<K, V> {
get(key: K): V;
set(key: K, value: V): void;
has(key: K): boolean;
}
export type Serializer = (args: any[]) => string;
export interface Options<F extends Func> {
cache?: Cache<string, ReturnType<F>>;
serializer?: Serializer;
strategy?: MemoizeFunc;
}
The tslint error output:
Argument of type '{ cache: { create(): { has(key: any): boolean; get(key: any): any; set(key: any, value: any): void; }; }; }' is not assignable to parameter of type 'Options<() => string>'.
Types of property 'cache' are incompatible.
Type '{ create(): { has(key: any): boolean; get(key: any): any; set(key: any, value: any): void; }; }' is not assignable to type 'Cache<string, string>'.
Object literal may only specify known properties, and 'create' does not exist in type 'Cache<string, string>'.ts(2345)
kaisermann and tdev9
Metadata
Metadata
Assignees
Labels
No labels