1

In Javascript I have:

var session = require('express-session');
var SequelizeStore = require('connect-session-sequelize')(session.Store);
new SequelizeStore({
    db: sequelize
});

I set these types:

function ConnectSessionSequelize(store: expressSession.IBaseStore): expressSession.IBaseStore;

This fails because expressSession.IBaseStore refers to an instance type, not a class type. Is there a way to specify class types, similar to Java: Class<expressSession.IBaseStore>?

Currently I'm using function CoSeSe(store: Function): Function, but this has major type leakage!

3
  • it sounds like Store should inherit or extend IBaseStore. does it? Commented Feb 20, 2016 at 19:08
  • It implements it: export class Store implements IBaseStore. Commented Feb 20, 2016 at 19:58
  • hm.. is there a specific error that you are getting? Commented Feb 20, 2016 at 19:59

1 Answer 1

2

The syntax typeof SomeClass will give you the type of the constructor function SomeClass (e.g. the type of x if you wrote let x = SomeClass) rather than the instance side (e.g. the type of y if you wrote let y = new SomeClass()).

Sign up to request clarification or add additional context in comments.

1 Comment

You are truly amazing: function CoSeSe(store: typeof expressionSession.Store): typeof expressionSession.Store.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.