Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return type of exported function has or is using name 'IMemoized' from external module "lru-memoizer" but cannot be named #10

Open
aschekatihin opened this issue Apr 8, 2019 · 0 comments

Comments

@aschekatihin
Copy link

Error in new Typescript 3.4:

clwy-node-jwks-rsa/wrappers/cache.ts(7,17): error TS4058: Return type of exported function has or is using name 'IMemoized' from external module "lru-memoizer" but cannot be named.

Example (from clwy-node-jwks-rsa):

export function cacheSigningKey(client: JwksClient, cacheMaxEntries: number = 5, options = {cacheMaxAge: ms('10h') }) {
  const logger = debug('jwks');
  const getSigningKey = client.getSigningKey.bind(client);

  logger(`Configured caching of singing keys. Max: ${cacheMaxEntries} / Age: ${options.cacheMaxAge}`);

  return memoizer({
    load: (kid, callback) => {
      getSigningKey(kid, (err, key) => {
        if (err) {
          return callback(err);
        }

        logger(`Caching signing key for '${kid}':`, key);
        return callback(null, key);
      });
    },
    hash: kid => kid,
    maxAge: options.cacheMaxAge,
    max: cacheMaxEntries
  });
}

As interfaces aren't really exported in typings - typescript guesses return type correctly as IMemoized here but cannot really use it.

So, as temporary fix

export function cacheSigningKey(client: JwksClient, cacheMaxEntries: number = 5, options = {cacheMaxAge: ms('10h') }): any {

works, but type info is obviously lost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant