threeDart/three.dart

More type annotations or type documentation please

Opened this issue · 3 comments

It's hard to tell what sort of parameters things take without diving into the code -- and not just looking at the source of the function I'm calling. I just got an exception inside CanvasRenderer.createPattern complaining that it received the wrong type or number of arguments. The stack trace is somewhere in the middle of CanvasRenderer.render() and probably indicates that I gave the wrong type of value to a texture or material constructor -- somewhere far away from any function in the stack trace.

Providing more type annotations where possible would help me catch these errors before I even finish typing them.

Actually, this exception that I got looks like it might actually be a different bug: CanvasRenderingContext2D says that createPattern takse a canvas_OR_image but it actually takes a CanvasElement or VideoElement. Still, more type annotations would be nice.

I also vote for more type annotations, at least as recommended here:
https://www.dartlang.org/articles/style-guide/#type-annotations
However, this is probably a legacy from porting from JavaScript.

I did a lot of this in #165, but there's still quite a bit to do.

Once #166 is resolved, I'd like to do another documentation pass and create a list of functions/types that still need documentation for things I can't figure out.

The style guide recommends adding type annotations for method signatures and omitting them for local variables (unless the function is long). There's an upstream issue for automating checking for missing annotations, but for now it's a manual process.