Type definitions

I will eventually get to this myself (but there’s a looong list of stuff like that), but if someone else wants to tackle this, note that the getdocs library which I’m using to generate the docs can be used to easily extract the type information from the source files. In many cases (though not 100% of them), creating .d.ts files could just be a matter of running getdocs JSON output through a template.