Error TS2304: Cannot find name 'Canvas2DContextAttributes'.
Jake,
I was working on a personal project, Polychromasia, when I ran into the error below. I'm not sure how to address this problem cleanly. Do you have any suggestions?
Thanks,
- Joshua
Hi, @jkaldon . Can I ask which version of TypeScript you are using, and can you share your tsconfig.json?
Never mind, I can see them. XD It's early.
So, it seems Canvas2DContextAttributes was removed from the standard typescript lib at some point. I'll have to look into this further.
If you add "skipLibCheck": true to your tsconfig.json you should avoid this error.
Okay, seems it was renamed here: https://github.com/Microsoft/TypeScript/commit/ee25cdecbca49b2b5a290ecd65224f425b1d6a9c#diff-46fd87925e4552c166ec188712741c3fR5899
I'll try to update when I have some time. 🙂
Cool, thanks!
In case it matters, here's my project: https://github.com/jkaldon/polychromasia-web
Hey, @jkaldon . Thought I should probably give you an update:
I have fixed the issue, but I can't publish it as there's something wrong with the documentation generation at the moment. I'm looking into this, but I'm a bit stumped - seeking help from the community.
For now a better solution than skipping the lib check might be to add a global alias for the renamed type.
You should be able to put the following in a global type declaration:
type Canvas2DContextAttributes = CanvasRenderingContext2DSettings;
I haven't tried this myself, but in theory it should work nicely. If you're not sure how to do this I'd be happy to fork your repo and open a PR for you. 🙂
Thanks for the update, @JakeSidSmith . For now, I'm content with your skip lib check option until the real fix is possible. I'm not really in any rush.
Just published 0.7.0 which should fix this issue. 😊
You'll want to npm i [email protected] as I've introduced some new bugs in 0.7.1 and 0.7.2. Oops.
Will be sorting those asap.