Open garyking opened 4 years ago
doing the argument signature would be doable but getting types on the API response shapes would be a lot of work without some kind of tool to automate it. I don't have a lot of time at the moment, but might take a stab at this later, or PRs are welcome!
I've created types just for the methods I'm using, for myself. I use http://json2ts.com/ to create the API response types.
I can tell you that the types are a mess though. Like, some endpoints will return a different format for the same property name.
Yeah I've noticed that they seem to have rather lax standards for API development and consistency.
EDIT: I figured it out, should have types soon.
@garyking do you have any experience writing d.ts
files for javascript libraries? I started a branch to add strong types but I can't seem to figure out how to export what I want. The docs for writing d.ts
files are strangely sparse; there are a lot of articles but they're old; not a lot of authoritative information that I could find.
If you check out that branch, you can generate the underlying types for each data endpoint with this:
WRITE_RESPONSES=1 yarn run mocha test/integration/data.js; node ./scripts/makeTypes.js
the library I used https://github.com/jvilk/MakeTypes seems to put out somewhat better definitions than http://json2ts.com/
It would be great to have TypeScript type definitions for this library. Thanks!