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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript declarations #401

Closed
cmoog opened this issue May 14, 2021 · 11 comments
Closed

TypeScript declarations #401

cmoog opened this issue May 14, 2021 · 11 comments
Labels
enhancement New feature or request

Comments

@cmoog
Copy link

cmoog commented May 14, 2021

Loving this new API 馃憤, great work all around.

TypeScript declaration files would be a solid UX improvement, making the API surface even more approachable for new comers.

@Fil
Copy link
Contributor

Fil commented May 14, 2021

I've never done this but a pull-request, even if it's incomplete, would help to get us started.

In particular I don't know how to test the coverage of ts declarations in CI.

A good starting point is probably the README.md API docs, which is the reference (source of truth).

@clhenrick
Copy link

Because Plot uses D3 under the hood, I believe this would be preceded by having up to date and well maintained TS declarations for D3. Currently the Definitely Typed package has some pain points that I've run into when using TypeScript with D3, which I imagine would affect the TS declarations for Plot.

@Fil Fil added the enhancement New feature or request label Jun 17, 2021
@kentr
Copy link
Contributor

kentr commented May 16, 2022

Because Plot uses D3 under the hood, I believe this would be preceded by having up to date and well maintained TS declarations for D3. Currently the Definitely Typed package has some pain points that I've run into when using TypeScript with D3, which I imagine would affect the TS declarations for Plot.

@Fil @clhenrick I've been experimenting with type declarations for Plot, so I'd like to know if any of the pain points that you referred to have been resolved with the recent work on the D3 types.

I'm referring to these updates:

@Fil
Copy link
Contributor

Fil commented May 16, 2022

Thank you for the work you are doing on d3 types! I'd be happy to see your experiments with Plot.

@kentr
Copy link
Contributor

kentr commented May 16, 2022

@Fil Ah, I mixed up my previous reply. I thought that the comment I quoted was from you, but now I see that it was not.

Those D3 updates are the work of some other wonderful people. I can't claim any credit for them. I'll create a PR for the Plot type experiments. They are very new, so it will be more of a starting point as you suggested than an actual request to merge.

@sgehrman
Copy link

Does Plot work with typescript or not? I'm getting errors.

@dgrcode
Copy link

dgrcode commented Aug 19, 2022

@sgehrman It does work with typescript, although there are no type declarations (as far as I know).

If you want to remove the type errors, what I've done to get it working is to create a file in your project declaring the types. For me that looks like the following:

// file /types/untypedDependencies.d.ts
declare module '@observablehq/plot'

It would be great to have types to get code completion and better linting though :)

@kentr
Copy link
Contributor

kentr commented Aug 30, 2022

If you want to remove the type errors, what I've done to get it working is to create a file in your project declaring the types.

Same for me.

It would be great to have types to get code completion and better linting though :)

The project has started converting files to TypeScript, but it looks like those files aren't in a release yet.

Edit: I was wrong. There are some TS files in a release.

@mbostock
Copy link
Member

Fixed in #1320! And more documentation to follow immediately.

@mbostock
Copy link
Member

mbostock commented Apr 1, 2023

Released in 0.6.5.

@cmoog
Copy link
Author

cmoog commented Apr 2, 2023

Wow, I just tried these out and they are incredible! The types, documentation, everything!

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

No branches or pull requests

7 participants