vega-lite-api icon indicating copy to clipboard operation
vega-lite-api copied to clipboard

Convert Project to Typescript

Open al6x opened this issue 6 years ago • 9 comments

  • It will be easier to develop
  • Easier to use for TS users
  • Still fully available to those who prefer JS

al6x avatar Dec 28 '19 21:12 al6x

A related issue to output Typscript: #9

domoritz avatar Sep 11 '20 17:09 domoritz

What if we added a .d.ts file to the existing project and defined the types field in package.json? Might be a smaller lift than rebuilding the project in typescript. If I were to make a PR to that effect, would that be helpful?

zekenie avatar Feb 06 '21 03:02 zekenie

Yes. People using Vega Lite from TypeScript would get compile time API validations and auto-complete hints.

P.S.

Although, doing incremental TypeScript conversion could be easy too, any not yet converted JS file could be used easily as const something: any = require("something.js").

al6x avatar Feb 06 '21 23:02 al6x

I did an hour of exploratory work, and I think this will be trickier than I thought. I'm autogenerating the types in the same way that the js files are currently autogenerated. It's hard only because I'm not familiar with the internals of this library, and still somewhat new to vega-lite. But, i think it will work. I might need to convert the build process to ts just to a handle on how the system works

zekenie avatar Feb 06 '21 23:02 zekenie

Thank you for doing the exploration. Note that we already use ts in many projects here such as Vega-Lite and Vega Embed so you can copy build setup code from there. I'm also happy to answer any ts/Vega-Lite questions.

domoritz avatar Feb 07 '21 00:02 domoritz

@domoritz wonderful! Is it important that I match the build conventions precisely, or are you offering that as a place to look for sensible defaults? Looking at the vega-lite build process it seems like there's quite a lot there, and we might get away with something a little simpler here?

zekenie avatar Feb 07 '21 00:02 zekenie

Look for inspiration. Vega embed has a simpler process for example.

domoritz avatar Feb 07 '21 08:02 domoritz

I did a little more work yesterday, and here's where I'm at ATM. I probably won't have time to pick it up again until next weekend.

  • I have an incremental migration to TS for the api folder, really just to add type annotations to help me understand the codebase.
  • I'm adding types to the api/types.js file and hitting some stumbling blocks, mostly because I don't fully understand the implied object types in this file. The diff I linked to shows my current state of understanding.
    • Things I'm still trying to make sense of:
      • What's the difference between these spec objects and the json schema?
      • Do these objects exist somewhere else in the vega ecosystem where I could look at them in context?
      • What are the object types represented here?

Don't worry if you don't have time to answer these questions! I'll take another crack at it next weekend.

zekenie avatar Feb 08 '21 15:02 zekenie

from all the graph libraries out there i think this is the most interesting, unfortunately a lack of documentation and modern developer tools makes it really hard to use this. if the author of this library wan't to achieve better adoption i suggest to produce more tutorials and especially add TS support, which would make developing with this library very easy and cool! i'm having a hard time figuring out how to translate the vega-lite examples out there into vega-lite-api, which is pretty inconvenient. TS support would help in this regard

letmejustputthishere avatar Jun 14 '22 15:06 letmejustputthishere