-
Notifications
You must be signed in to change notification settings - Fork 176
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
Moving from dt/node to env/node #749
Comments
@Zelein the express-server-static-core typings are simply wrong. They use the |
Just ran a build with the updated typings, everything is green 👍 |
Okay, great. Thanks @felixfbecker. I will work on switching that over. I'm having problems integrating the new typings express with some custom Swagger types. But I will work that out. |
One way they differ is that they do not add |
Is there a way to augment the express Request type? |
No, you have to do it explicitly with union types. It allow you to selectively only enable properties on |
I thought this was possible to do with Declaration Merging? I was able to previously extend the Request type in a separate .d.ts file to include the properties that were being patched onto the Request object in the middleware stack. Forgive me if this has changed, I am still learning the ins and outs of TypeScript. |
I'm sure it would be possible with some workaround, but honestly it's a bad pattern. The properties are only available when you actually used the middleware, so you should also type Request explicitly with the added attributes |
And by that you mean anywhere I am using express.Request, I have to extend it with a Union like you stated above? |
yes :) |
Thanks for the help Felix. It really is unfortunate that even for TypeScript 2.0, the @types/express is using what is currently in DefinitelyTyped, not the correct one that is in Typings. |
Yes, they publish from DT, even though types has much higher quality typings. See microsoft/types-publisher#51 and microsoft/types-publisher#4 |
@Zelein Sorry for that deletion. I run into the bug myself when I started using I also started following the intersection pattern over union which is really much nicer and can avoid some issues around when a middleware is unused. I still use module augmentation in one place, which is for a global middleware function. Should we close this and log an issue on DefinitelyTyped to stop using the deprecated http interfaces? |
Could you elaborate? This is only available in TS 2.0, right? |
Thanks for the response. Sure, close the issue out. Something definitely needs to be done to sync I noticed recently Webstorm telling me http.ClientResponse has been On Sep 2, 2016 18:19, "Blake Embrey" notifications@github.com wrote:
|
@felixfbecker Sorry, using @Zelein The odd thing is, it's been out forever (even 0.10 used |
Wow, yeah. It will probably break a lot of people's TS projects. It should probably be done at some point, especially once the TS 2.0 types gets figured out. Ideally the typings version will get the preference since it is the most accurate. |
Hey,
I'm posting this here as I didn't know where else to post..
I just moved from the dt/node@4 to the env/node@4 and the latest change to env-node has broken my builds. I'm using the dt version of express with "express-serve-static-core" virtual module.
That module is not playing nicely with the recent change to node-env (as it shouldn't) since it is referencing deprecated http modules. What is the recommended upgrade path to get express working again?
Referencing this pull: #748 and this issue: env-node #34
The text was updated successfully, but these errors were encountered: