@types/xxxx package and had problems.Definitions by: in index.d.ts) so they can respond.I get this error when trying to use typings for the got package:
node_modules/@types/got/index.d.ts(85,50): error TS2304: Cannot find name 'URL'.
Not sure if that's the cause, but this definition imports Url (that is not used) and uses URL (that is not imported).
node v6.11.2
npm 3.10.10
typescript 2.5.2
URL is available in the dom typings provided by TypeScript. It's a global there so it doesn't need to be explicitly imported. It's the same type that is exported by the url module in node typings in v7 and 8. This way I've tried to make this module usable for users of node typings <7.
And Url is actually used here.
Thanks @BendingBender. I solved this by adding dom to the libs in tsconfig.json.
I was actually thinking of brining this up earlier but never got the time. In my backend projects I don't feel that I should need to enable dom since that's not available in that environment...
I'm not sure if there is any better solutions though, but one way could be to type a small interface of the props that got actually looks at. It's to my understanding that it would then be perfectly fine to pass it an URL class
Same for me here (like @LinusU said). got is a universal package and so is my package. It might be running in a DOM environment, but might also be running in node.
Thus adding @types/dom would be quite a dirty hack, since we cannot rely on any DOM stuff to be available.
I don't understand the rationale for closing this one. Is it acceptable to include the dom even if it isn't actually available?
I don't like this solution either, but it works. I think it would be better if got do not depend on @types/dom.
Most helpful comment
I don't understand the rationale for closing this one. Is it acceptable to include the dom even if it isn't actually available?