various bugfixes in d3.d.ts

Bugs were found using the tscheck tool: https://github.com/asgerf/tscheck

I am the author of tscheck, and I made this patch as a proof-of-concept. The patch was written by hand to fix the problems detected by tscheck.