-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 .d.ts #4876
Comments
with the increasing popularity of TypeScript, I think this needs to happen. Many other js packages are starting to include their own (official) typings now. Rather than leave it up to the DefinitelyTyped community |
This is something we are considering. It should be possible to make a node script to auto generate it from our API dump. |
+1 👍 from me as well. The DefinitelyTyped repo is outdated, where after Highcharts v4.2.x only sporadic and incidental properties were updated. But most of the changes in Highcarts are simply not processed. So either the DefinitelyTyped repo should be updated or - more convenient - having it bundled with Highcharts would even be a much nicer solution. Having it auto-generated sounds like a great option, but this might still require manual labor on the part of writing tests for the .d.ts file? Also, having it auto-generated might be. I'd be willing to do some work in updating the DefinitelyTyped repo to the current release, and do a PR on https://github.com/highcharts/highcharts if you want to include the manual file there? |
^ I've created a PR for the DefinitelyTyped repo that implements Highcharts v5.0.10. If anyone is interested, this might be a good place to work further on (once and if it gets merged). At least for the time being, until the TypeScript definition file is deployed along with Highcharts itself. |
Having official TypeScript type definitions would be highly appreciated. Helps a lot when typing out a chart config. |
Here we are again with the type definitions a major version behind reality. :/ Given the complexity of this library I think the best solution is to generate the type-defs from the "API dump" that @TorsteinHonsi referred to. However that link appears to be broken. Is there a new one? I would be willing to take a stab at writing a generator. |
Yes, the new one is available from https://api.highcharts.com/highcharts/tree.json. This tree is generated from our JSDoc comments and parsed source code. @cvasseng FYI. |
@TorsteinHonsi Thanks I'll take a look at this. Are you using a particular flavor of "jsdoc" (Google Closure, JSDoc 3?) Does the JSON dump happen somewhere in this code-base I can look at for reference? The reason I ask is because there are existing JSDoc-to-TSDef convertors out there which might work... |
We are using JSDoc 3, but heavily extended to be able to describe our declarative options structure. |
@TorsteinHonsi Looking at the JSON I have a few questions... you don't by any chance have a schema documentation on this format? This is what I've collected. How do you designate options that are passed to |
Hi @aaronbeall, we don't have any thorough documentation on the schema at this time, but it looks like you got it all in your definition. The options for As a side note, the old dump format was available at https://api.highcharts.com/dump.json, we've now moved it back to the original position at https://api.highcharts.com/highcharts/option/dump.json. |
Thanks @cvasseng. I'm starting to tinker with this... there's a lot of data, I have my work cut out for me just to understand it all. :) I noticed some fields have no type and no default to infer the type from, such as (I'll have more questions, is there a better place to discuss this? Gitter? I'm fine here but it's probably creating quite a bit of noise for some people.) |
The type for We don't have a schema for namespaces/classes, but those are handled by vanilla JSDoc 3, so it may be possible to add an existing plugin to automatically generate typescript definitions for them. The setup for that part can be found here: https://github.com/highcharts/highcharts-docstrap And discussing this here works just fine. :) That way we have a central public place for it, so that others may follow it too. |
In case it's helpful this is a dump of all the fields (in highcharts/tree.json) that don't seem to have a type. A quick scan over the inferred types from default values (string, number, boolean) looks correct to me, but the ones that say "Unable to determine type" mean I didn't find a There's also a blank key in the top-level JSON and in |
I made some progress on this today, you can see what's currently been generated here. There's a lot of work left to make this high quality. I'll push to a repo tomorrow. At a high level some issues I ran into:
Some other specific things:
|
Also, some of your missing types are not missing in the API, for example https://api.highcharts.com/highstock/plotOptions.bb.topLine.styles.lineColor. If I remember correctly we do type guessing in the |
@cvasseng What is the status on our official TypeScript definitions? |
Uploaded a repo to play with this, no additions today though.
I'd be curious to understand how the Edit: Small bit of progress tonight, my truthy check for default value was discarding all literal |
Made some progress after thinking about how the tree extends objects:
What's next
Questions
|
@aaronbeall do you have any progress? I've also dive a little bit into type generation for highcharts. One major flaw is that the generated |
@scott-ho It's been a little bit because I moved off the project using Highcharts in the new year, but I am back on it now and will get back into this project soon. From my last post I went down the route of converting
What method of pruning are you referring to? This has been the hardest part to deal with... Yes, I also noticed that that the classes/namespaces are not described in |
All of the data collection for I think there could be some misuse of jsdoc api inside it. We could figure out a better way to generate a new version of |
Today, I spent a while to find out what the Types collecting and generation logic is written here - https://github.com/highcharts/highcharts/blob/master/tools/jsdoc/plugins/highcharts.jsdoc.js. We might need to generate the full-version of types ourselves and do something similar to https://github.com/englercj/tsd-jsdoc. |
We now work on the quality and try to reduce the number of generated interfaces in the options tree of Highcharts. After this we will start a public beta phase. Our ETA is for now the 3rd quarter 2018 for the Beta. |
@sophiebremer That's great news! Do you have a DTS generator or are you using an existing conversion tool? |
We use a custom one. We tried the approach of this pull request #8307 using dts-dom underneath, but this did not work well. |
Any news on this one? It seems that |
We are still working on this with high priority. Unfortunately I can not publish a preview of the declaration right now. There are still types, that need to be consolidated, or that need to be introduced. The "highcharts.d.ts" will be a huge file with more than 200.000 lines of declarations and comments. |
@sophiebremer how do you produce that file? Manually? |
@scott-ho |
Hi everyone! I published a preview of the declarations for Highcharts in my personal repository. You can test it by Known issues:
|
ChartEventsOptions functions like selection do not seem to be taking in the event function parameter |
Couple of other issues that I found
|
Thank you for the feedback, @muperi !
|
Fix is part of #9110 and will be included in next update of https://github.com/highcharts/highcharts-declarations-beta. |
Please add further issues with the declaration files to this repository: https://github.com/highcharts/highcharts-declarations-beta. Thank you. |
Is it possible to you to deploy the definitions for Typescript for Highcharts within the npm package (like angular)?
The text was updated successfully, but these errors were encountered: