-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
TypeScript typings pollute global types by including lib.dom.d.ts #1656
Comments
Good point... any chance you know of a solution, aside from copying and pasting the relevant definitions into our typings file? Copying them might not be a bad idea anyway. There are a few subtle errors in the current definitions because we don't 100% match the HTML Canvas spec. |
I'm not aware of a solution that wouldn't involve copying and pasting the official definitions. Like you said, doing that is probably not a bad idea after all. |
I just ran into this. It's super unfortunate that TypeScript works this way, as it can be really bad for Node or Node-and-browser codebases. I've been skeptical before that node-canvas should use the DOM types at all. The types should match what we support perfectly, not the upstream types which might add features we don't support yet. If people want to draw to a context that's compatible with both DOM and node-canvas, they can accept an intersection of the two types. |
Issue or Feature
types/index.d.ts contains the following line:
It references lib.dom.d.ts, which usually isn't included in Node.js projects. This makes TypeScript think
document
,requestAnimationFrame
and other browsers-only APIs are available in the global namespace.Steps to Reproduce
As expected, the code will not compile because
document
doesn't exist in Node.js.The code will now compile despite being invalid.
Your Environment
npm list canvas
oryarn list canvas
): 2.6.1The text was updated successfully, but these errors were encountered: