Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript type definitions #83

Open
garyking opened this issue Jan 9, 2020 · 4 comments
Open

TypeScript type definitions #83

garyking opened this issue Jan 9, 2020 · 4 comments

Comments

@garyking
Copy link

garyking commented Jan 9, 2020

It would be great to have TypeScript type definitions for this library. Thanks!

@bttmly
Copy link
Owner

bttmly commented Jan 10, 2020

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!

@garyking
Copy link
Author

garyking commented Jan 11, 2020

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.

@bttmly
Copy link
Owner

bttmly commented Jan 13, 2020

Yeah I've noticed that they seem to have rather lax standards for API development and consistency.

@bttmly
Copy link
Owner

bttmly commented Mar 21, 2020

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants