koajs / koa-redis

Redis storage for Koa session middleware/cache with Sentinel and Cluster support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

typscript conflict between @types/koa-session and @types/koa-generic-session

alsoscotland opened this issue · comments

Thanks for maintaining the project. I am curious if there is an ETA or plan to accept
#35
#56

I am running into a typescript compilation error when trying to setup up a project with koa-redis/koa-session. I think the upgrade would alleviate the issue of conflicting session types in these two dependencies.

node_modules/@types/koa-session/index.d.ts:205:9 - error TS2717:
Subsequent property declarations must have the same type.  Property 'session' must be of type 'Session | null', but here has type 'Session | null'.

205         session: session.Session | null;
            ~~~~~~~

  node_modules/@types/koa-generic-session/index.d.ts:58:9
    58         session: koaSession.Session|null;
               ~~~~~~~
    'session' was also declared here.

Thanks for updating to v4.0.0 and koa-session. any chance of adding type definitions here. I have been using the ones at definitely typed. They are a relatively small definition but I was having a bit of trouble trying to adjust them to work and get definitely-typed running locally to confirm that an update worked.

The current definitions are:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/koa-redis/index.d.ts

// Type definitions for koa-redis 3.0
// Project: https://github.com/koajs/koa-redis
// Definitions by: Nick Simmons <https://github.com/nsimmons>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3

import { ClientOpts } from 'redis';
import { SessionStore } from 'koa-generic-session';

declare namespace redisStore {
    interface RedisOptions extends ClientOpts {
        duplicate?: boolean;
        client?: any;
    }

    interface RedisSessionStore extends SessionStore {
        client: any;
    }
}

declare function redisStore(options: redisStore.RedisOptions): redisStore.RedisSessionStore;
export = redisStore;