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
webpack-env.d.ts does not compile with node.d.ts #8018
Comments
Well, technically you are still not in node environment and it's not correct to include the entire node.d.ts file. You are using an npm package that acts the same as node's "url", but in browser environment. What you can do is extract those typings from node.d.ts and have a separate url.d.ts, like you already suggested. Just splitting node.d.ts into smaller modules may not suit every need, because the signatures may be different due to environment differences (Buffers vs Arrays) or implementations. I would suggest an independent typing for this "url" package. |
I sort of ran into the same issue where I use include
|
The way I "solved" it was to create a separate typings file for the node-specific modules I wanted to use. Bit of a hack, unfortunately. |
I ended up removing webpack-env altogether as I only needed one typing in my entire project for that. Hopefully it stays that way. I tried your solution but I really don't like polluting my files with references as much as possible. Thanks for the reply Saurabh Sharma / Quality Engineering
|
Sure, neither do I :( But I needed that module, sadly. @foklepoint |
but what if
😢 |
Before you ask: Yes, I searched - and found #6334 - although this does not address my issue.
I'm writing a web application that uses Webpack. As a result, I do need access to
webpack-env.d.ts
in the front end, but I'm also interested in using theurl
module from Node (forurl.parse
). If I requirewebpack-env.d.ts
andnode.d.ts
in the same references file, predictably it breaks because Node re-definesrequire
. IOW, I need access tonode.d.ts
'surl
module and webpack'srequire
definition.I can get around this by using
const url: any = require('url')
, though this isn't ideal and I'd like to have typings for this module. Another option would be to splitnode.d.ts
into its constituent modules and have the masternode.d.ts
require each individual module, though I'm not sure if this would break anything from the many people who rely on this TypeScript declaration file - and I don't particularly want to hack it together locally.Any suggestions?
The text was updated successfully, but these errors were encountered: