Skip to content

Cache TypeScript support #43

@robert-nash

Description

@robert-nash

I am using this library with nodecache as below.

import nodecache from "node-cache";

const flagsmith = new Flagsmith({
    environmentKey: "xxx",
    cache: new nodecache({
        stdTTL: 10,
        checkperiod: 10,
    }),
});

export default flagsmith;

I get the following type error on cache:

Type 'NodeCache' is not assignable to type 'FlagsmithCache'.
  The types returned by 'get(...)' are incompatible between these types.
    Type 'Promise<Flags> | undefined' is not assignable to type 'Promise<Flags>'.
      Type 'undefined' is not assignable to type 'Promise<Flags>'.

I wonder if this is a problem with the Flagsmith Types? It seems to make sense that the get method will return undefined when the key does not exist in the cache.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions