Convert Project to Typescript
- It will be easier to develop
- Easier to use for TS users
- Still fully available to those who prefer JS
A related issue to output Typscript: #9
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?
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").
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
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 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?
Look for inspiration. Vega embed has a simpler process for example.
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
apifolder, really just to add type annotations to help me understand the codebase. - I'm adding types to the
api/types.jsfile 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?
- Things I'm still trying to make sense of:
Don't worry if you don't have time to answer these questions! I'll take another crack at it next weekend.
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