-
-
Notifications
You must be signed in to change notification settings - Fork 987
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
Import & update typings from DefinitelyTyped #656
base: master
Are you sure you want to change the base?
Import & update typings from DefinitelyTyped #656
Conversation
I just noticed that although the readme says that a store must be an Is the readme wrong or is being an |
Turns out declaration merging doesn't work properly with these definitions, currently investigating. |
I have addressed your concerns, including a crude concept of additional documentation in the readme. What do you think about my suggestion to remove the optional modifier on |
So i have not finished reviewing yet, just things I found from a first look.
I don't know what this means, can you elaborate if you need an answer from me?
It is required. Try making a store without it and it will fail immediately since this module attempts to add event listeners to the store during set up. Not sure what the confusion is. |
Typescript employs strict null/undefined checking, which basically means that the compiler screams at you for using a nullable/undefinedable reference without the proper checks. It's really inconvenient in this case, although technically correct to have the
Apologies, I completely missed this line which effectively causes all store implementations to implicitly extend |
Well, I've never used typescript and still this seems over my head to be able to answer. |
I found another possible mistake in the typings which boils down to the following: do the functions on the |
I have decided to drop the optional modifier on I also decided to give the Lastly I took another shot at the whole cookie system hierarchy. I think I got it right this time, but you should definitely check my summary in the comment above in case I missed something. Are there any more changes you'd like to see before this can get merged? |
Thanks so much! I will take another review though them due to the number of changes to double check as well 👍 As for next steps, ignoring the outcome of the review, it would be nice to...
|
Don't ask me how but I never noticed that the tests are failing. No idea how that can happen by the addition of typings but I'll take a look.
I'll see how DefinitelyTyped does this, since they're the biggest (hand-maintained) repository of TypeScript definitions.
No idea actually. It's probably going to conflict somehow with the DefinitelyTyped version but I'm not sure how well the TypeScript compiler handles duplicate typings. It would make sense for it to only use the in-package definitions but I don't think that's actually how it works. However, if this gets merged the DefinitelyTyped package will ultimately be deprecated/removed providing existing TS users with a nice little warning that'll tell them there are new (and improved) definitions. |
So the safe to land in 1.x is, overall, my main concern. Is there any way to gather what would happen to an existing app? |
Do you know a codebase I could test on? |
No, I have not used TypeScript before. |
Turns out CI is only failing in Node v0.8, probably because it's just too old to install the |
It's been 8 months now, is there any chance of this getting merged soon? Little note to myself: notify JLuboff/connect-mssql-v2#10 when this is merged. |
Wouldn’t it be possible to make the types optional dependencies? They are probably failing because they are scoped dependencies that such an old npm version cannot handle? Landing this in 1.x would be preferable as any future 2.x is just that – something that eventually happens at some point in the future. |
I'm not super familiar with typings, so can't really say. Besides the node.js change in this PR, I would assume if these landed in a 1.x version it would still break typescript projects, since the typings here are not compatible with existing typings folks are using, is that a correct assumption? |
I don't fully understand what you're trying to say here.
I don't fully remember, but I'd be surprised if these new typings don't break something. These changes definitely need to go into a new major version, but I agree with what @voxpelli says (I think). It's been 8 months since I submitted this PR, and (as far as I can tell) v2 hasn't come any closer. You say you want to wait with releasing v2 until all v1-PR's have 'landed', which makes a lot of sense, but if there's no work being done to reach this point it could take years to resolve this mess. I'm not saying there's nothing happening, because I honestly have no idea if that's the case. I haven't used this module for several months, the only reason I checked in was because a downstream maintainer asked for a status update (chill117/express-mysql-session#93 (comment)). The current typings mess is (most likely) affecting everyone who uses this library with TS, so I think it's fair to say that a quick solution would be appreciated by a lot of people. I don't want to rush you or anything, I'm just trying to help resolve this typings mess, in the hope that others won't have to go through the same troubles as me. |
English is not my first language, so I'm sorry if I seem a bit blunt. Perhaps it'd be possible to release v2 before all PR's have landed? |
If you really need a quick solution, why can the typings not be updated in definatelytyped? Wouldn't that solve everything at concern here? Since that is a separate dependency folks can pull in the version of types that work for them without breaking others and then the others have a chance to migrate? Especially since the types are for the 1.x of this module. |
I'm ultimately not interested in releasing a major version of this module just to fix typings I never made. I'm happy to land them in here in conjunction with the other badly-needed changes. But I'm not sure why now the pressure is on a module and person who did not make a bunch of broken typings in the first place... this will be landed along with 2.0, but if you really need to "fix the mess" that is not even part of this module, land the fix in definitelytyped in the interim. Folks can use their package.json to refer to the relevant type definitions. |
Note I have locked this thread temporarily while I can get some samesite cookie releases out tonight for folks and can resume this discussion at a later time. One thing to consider for later is who will keep the types up to date with changes in this module? Landing this before the other PRs will make them unlandable as-is since the types will be off. I just want to get those out of the way before we land the types so they are at least not just immediately out of data again. This week I will start a 2.0 beta branch to start getting things landed. We will use that as a test to see if there is anyone who helps keep the types up to date though those changes in the beta as a test for them going in the final release. That is just a proposal, and we can further discuss. I will open a meta issue so things are not lost. |
Hi @HoldYourWaffle I have unlocked at your request, but I just want to make sure that you (not I) say anything rash is all. Many times I observe when a github issue or pr turns into a chat (based on the speed of responses) it can get out of hand (and I'm not always not at fault either). Especially because responses can be long and both people end up typing and posting at the same time, reading each other's response and again and again :) I don't want PRs just hanging around just like you expressed, but there is a lot going on in the conversation here. I hope some of the previous posts will have some clarity, and I'm going to commit to getting this landed in a 2.0 line this week for all involved here. |
Thank you for (temporarily) reopening this. But you're right, in this case it may be the proper solution. After all, these situations are sort of what DT was meant for in the first place. I'll see if I can create a PR over at DT soon, if you chip in to say that these typings match (like you did when you reviewed the PR) it should go smoothly. I'd still prefer including the typings in the module itself eventually, but this way you don't have to rush v2. |
Sounds good. I will be happy to confirm the types on there. Note I only temporary locked it; it will remain open unless there is a reason to lock again, so you don't need to worry about it just suddenly going locked without warning :) |
I have just created the PR to update the definitions over at DT. |
I have just created a second-attempt PR to update the definitions over at DT, could you (@dougwilson) check if these are still accurate after a year? |
I have updated the imported definitions to the current latest DT candidate (PR). I'll update my published fork shortly. To increase my developer-citizen-karma, I have copy-pasted (and reformatted) the documentation from the README into the type definitions as tsdoc. Unfortunately I couldn't find anything on Did I miss something or is there really documentation on these properties/methods? |
I'm happy to inform you that DefinitelyTyped/DefinitelyTyped#46576 was (finally) merged! I'd still like these typings to be merged here some day, because (as you might've seen) DT can be a bureaucratic mess... |
9d2e29b
to
408229e
Compare
The current DefinitelyTyped typescript definitions for this module are a mess. They're needlessly convoluted and in some ways outdated or wrong.
Because my definitions would be a breaking change and because DT is a mess in general (giant mono-repo, having to install another package) I suggest merging these definitions into the main repository.
I made 2 commits to make the difference between the DT definitions and mine clearer, I'd be happy to squash them before this is merged.
Changes relative to the DT definition
regenerate
,load
andcreateSession
are not functions onStore
. I'm not sure why they were there in the first place, I thinkSession
has similar methods but they aren't a proper match.Express.CookieOptions
forSessionCookie
¹SessionData
no longer has astring => any
index type. This makes it possible to use declaration merging to allow the user to type their own sessions. This is also seen on express's Request type.BaseMemoryStore
,MemoryStore
just extendsStore
Notes
Express.Request.session
andExpress.Request.sessionID
. Although they're technically 'optional' in the sense that they don't exist before youuse
your session middleware it's really inconvenient when working with strict null checking enabled. If you haveuse
d the middleware these properties are guaranteed to be there, making any checks redundant. Because of this I'd suggest going for convenience rather than accuracy in this instance.Cookie
class here but I'm not sure how it's used and how to represent it in these definitions. I made it an interface which extendsExpress.CookieOptions
for now but I'm pretty sure this neither accurate nor semantically correct.@horiuchi, @jacobbogers, @builtinnya and @ry7n, you are credited as the original authors of the DT definitions. I have a couple of questions about why they are the way they are:
BaseMemoryStore
and several inheritances redefined common functions.