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

Type Definitions #10

Closed
JLuboff opened this issue Nov 21, 2019 · 6 comments · Fixed by #12
Closed

Type Definitions #10

JLuboff opened this issue Nov 21, 2019 · 6 comments · Fixed by #12
Labels
bug Something isn't working

Comments

@JLuboff
Copy link
Owner

JLuboff commented Nov 21, 2019

Need to straighten out type definitions. Currently, Store accepts an argument of session with type any and returns with type any. In turn, does not properly supply types.

@JLuboff JLuboff added the bug Something isn't working label Nov 21, 2019
@bradtaniguchi
Copy link
Collaborator

bradtaniguchi commented Nov 22, 2019

I was looking into this and found this repo, which implements another express-session store, but in typescript for typeORM it extends the Store class/type/instance.
https://github.com/nykula/connect-typeorm/blob/master/src/app/TypeormStore/TypeormStore.ts#L59

I was messing around with the types and noticed all the function types need to be arrow functions rather than instance methods (what we have right now). I'm not 100% sure how these are mapped right now, but apparently everything is working as expected.

I'm going to update the types and change around how we declare the methods to be arrow functions and open a PR.


edit I did more digging into the types and noticed something. The arrow functions are defined via some type definitions, but they actually seem wrong, in that every implementation of the session store I've seen uses prototype IE instance methods (which sounds like the right way). I'm going to dig into it more and see if I can override it or something and then maybe we open an issue on the offending types :)


edit after even more digging I ran into this issue, which talks about having express-session handle its own types. This is suppose to land in version 2 of the lib, as it could break with the DT versions (which we are using).

Generally the DT versions are a mess, if that wasn't clear with all my above comments haha. Basically fixing the types now against the express-session types doesn't seem like the best idea due to all the underlying issues with the types in the first place.

As such the internal existing types should be good enough, I'll update just the public facing api to match with the express-session types.

@JLuboff
Copy link
Owner Author

JLuboff commented Nov 22, 2019

@bradtaniguchi Thanks for the work on this! I was struggling trying to figure out the whole instance method vs instance function error. Your digging seems to have discovered why 👍 I'll go ahead and merge the PR and we'll keep a look out for updated express-session types, at which point we can update as needed.

JLuboff added a commit that referenced this issue Nov 22, 2019
@HoldYourWaffle
Copy link

after even more digging I ran into this issue, which talks about having express-session handle its own types. This is suppose to land in version 2 of the lib, as it could break with the DT versions (which we are using).

I'm the author of the PR you linked, and yes, the DT typings are an absolute mess.
The PR to fix the typings for express-session has been on-hold until v2 for 8 months now, I'll post another comment as soon as it's merged.

@HoldYourWaffle
Copy link

Because express-session will need to do a major-version-update to include the type definitions I have (temporarily) opted to update the definitions over at DT.

@HoldYourWaffle
Copy link

I'll post another comment as soon as it's merged.

It has been 20 months, but I'm happy to say that DefinitelyTyped/DefinitelyTyped#46576 has just been merged!

@bradtaniguchi
Copy link
Collaborator

@HoldYourWaffle Thanks! Seemed like a real battle to get it through!

Going to be looking into refactoring the types here with the new changes :D

Thanks for all the effort!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants