-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add typescript definitions #303
Conversation
Codecov Report
@@ Coverage Diff @@
## master #303 +/- ##
=======================================
Coverage 88.27% 88.27%
=======================================
Files 82 82
Lines 1049 1049
Branches 206 206
=======================================
Hits 926 926
Misses 107 107
Partials 16 16 Continue to review full report at Codecov.
|
We've been maintaining our own typings for (a subset of) RJH, so this is really great! You haven't considered moving the codebase towards typescript? I realise it's quite some work to get there, but I think it would be worth while. If not, please make sure to keep the typings up-to-date. Misleading types are worse than no types. |
Can you please paste this definition to your module declaration and report if it works for you?
That's up to whawker to decide. Previously typescript was quite cumbersome to use with react, but latest releases have been better. It's however quite an effort and adds complexity. |
We're using the react-jsx-highstock package and the highstock specific components are missing, but other than that it seems to work. There are a few |
Do you happen to have definitions for those? |
Well, I would have to go through the components and look at the code. One simple example is |
I added type for |
Nice @anajavi, this is looking good! I would like to have the event handlers listed out though, instead of |
Something like this should probably work: type ChartProps = {
onSelection?: Highcharts.ChartSelectionCallbackFunction;
[x: string]: any; // TODO: this is here to allow eventhandlers like onAfterAddSeries
} & Partial<Highcharts.ChartOptions>;
export function Chart(props: ChartProps): ReactElement; There are however more events in highcharts than there are in their typings. One example is |
@anajavi Great! Seems to work just fine :-) Just wondering about the highstock package. Will that one get these typings? It will need some of it's own as well, but for typescript to figure out where to look based on the import, all types must be present in the highstock package as well. |
I think we should land react-jsx-highcharts types first. When the types have been released it is easier for somebody(you?) to make a PR for highstock. |
To be honest I don't know Typescript, so I would struggle to maintain the project. It is something I intend to learn but I don't use it day-to-day currently, like I do with JS
Worth releasing as a beta first? |
This certainly won't break anybodys application, but might confuse a bit. Maybe a beta release and mention in the #259 might get some feedback? I intend to add some kind of test or eslint configuration for this later so we see if new highcharts release breaks the typings(most likely the eventhandlers). |
Works nicely at my end. |
This builds on whawker#303 and extends types to also cover the react-jsx-highstock package. Please verify that the type definitions makes sense, @anajavi and and @whawker. I used the types you defined, @anajavi, as reference and tried to compare props of RJH components with Highcharts config types. It works for our usage of RJH, but not all components are tested.
what?
This adds typescript definition for the library. Not complete, but all series types should have types.
References highcharts types.
Somewhat related to discussion in #113 and in #267 (comment)
why?
caveats
I am no way expert in writing definition files. I suggest that we release this and see what happens? It's easy to remove if it causes too much a headache. Maybe adding something in the release notes about "beta types".