JakeSidSmith / canvasimo

An HTML5 canvas drawing library, with 150+ useful methods, jQuery-like fluent interface, and cross-browser compatibility enhancements.
http://canvasimo.com
MIT License
16 stars 2 forks source link

Error TS2304: Cannot find name 'Canvas2DContextAttributes'. #120

Open jkaldon opened 5 years ago

jkaldon commented 5 years ago

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,

Canvasimo Error
JakeSidSmith commented 5 years ago

Hi, @jkaldon . Can I ask which version of TypeScript you are using, and can you share your tsconfig.json?

JakeSidSmith commented 5 years ago

Never mind, I can see them. XD It's early.

JakeSidSmith commented 5 years ago

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.

JakeSidSmith commented 5 years ago

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. 🙂

jkaldon commented 5 years ago

Cool, thanks!

In case it matters, here's my project: https://github.com/jkaldon/polychromasia-web

JakeSidSmith commented 5 years ago

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. 🙂

jkaldon commented 5 years ago

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.

JakeSidSmith commented 5 years ago

Just published 0.7.0 which should fix this issue. 😊

JakeSidSmith commented 5 years ago

You'll want to npm i canvasimo@0.7.0 as I've introduced some new bugs in 0.7.1 and 0.7.2. Oops.

Will be sorting those asap.