GithubHelp home page GithubHelp logo

Comments (25)

BrandonWilliamsCS avatar BrandonWilliamsCS commented on July 25, 2024 12

I created a types file for my personal use; hopefully it serves as a good starting point for someone to do so more formally (whether part of the package or in DefinitelyTyped). However, some work definitely needs to be done before Highstocks and Highmaps are covered.
It's short, so I'll just paste the contents @types/highcharts-react-official/index.d.ts (where @types is parallel to node_modules).

declare module "highcharts-react-official" {
    import * as React from "react";
    import * as Highcharts from "highcharts";

    /**
     * Represents a "constructor" function for a ChartObject.
     * Not technically a constructor, as it's not called with `new`.
     */
    type Constructor = (
        renderTo: HTMLElement,
        options: Highcharts.Options,
    ) => Highcharts.ChartObject;
    /**
     * Represents all of the strings that are keys of T that map to a Constructor function.
     */
    type ConstructorName<T> = {
        [K in keyof T]: T[K] extends Constructor ? K : never
    }[keyof T];

    export interface HighchartsReactProps<TContainerProps = {}> {
        highcharts?: Highcharts.Static;
        constructorType?: ConstructorName<Highcharts.Static>;
        update?: boolean;
        options: Highcharts.Options;
        containerProps?: TContainerProps;
    }
    export class HighchartsReact<TContainerProps = {}> extends React.Component<
        HighchartsReactProps<TContainerProps>
    > {}

    export default HighchartsReact;
}

from highcharts-react.

KacperMadej avatar KacperMadej commented on July 25, 2024 2

Hi @JannesMeyer

For the wrapper?

If, for the Highcharts then please refer to this issue - highcharts/highcharts#4876

from highcharts-react.

jonfreedman avatar jonfreedman commented on July 25, 2024 2

Is there any ETA on this?

from highcharts-react.

bre1470 avatar bre1470 commented on July 25, 2024 1

Hello! We will also work on declarations for Highcharts React. Development will start with the end of the beta phase for Highcharts declarations.

from highcharts-react.

JannesMeyer avatar JannesMeyer commented on July 25, 2024

Hi @KacperMadej !

Yes, for the props of the HighchartsReact component. (options, highcharts, constructorType, etc...)

I see in the other issue that you are unable to provide type definitions for the options, but you could already provide types for the other two props.

Of course, the main issue is adequate typing for the options prop...

from highcharts-react.

JannesMeyer avatar JannesMeyer commented on July 25, 2024

By the way, the company I work for has a single developer license for the Highcharts Suite with the Premium Support.

Let me know if you want me to email the proof of license.

from highcharts-react.

KacperMadej avatar KacperMadej commented on July 25, 2024

For technical support please use support channels - https://www.highcharts.com/support

It would be for the best to keep issues in github for bugs - at least this it what we are trying to do.

from highcharts-react.

JannesMeyer avatar JannesMeyer commented on July 25, 2024

Ok, I have written an email to [email protected] requesting this enhancement.

Sorry for using the wrong channel.

from highcharts-react.

KacperMadej avatar KacperMadej commented on July 25, 2024

Not a problem. I'm keeping this issue open and labeled as an enhancement.

from highcharts-react.

dandv avatar dandv commented on July 25, 2024

See #36. Official definitions are expected in Q3.

from highcharts-react.

JonasGilg avatar JonasGilg commented on July 25, 2024

As specified in #36 the official definitions are only for the normal highcharts api. So we still need official definitions for highcharts-react.

from highcharts-react.

JannesMeyer avatar JannesMeyer commented on July 25, 2024

I agree with @TheJhonny007. Pull request #36 is only for the options attribute. Like I mentioned in my first comment, there would still be the need for types for the rest of the HighchartsReact component.

from highcharts-react.

JannesMeyer avatar JannesMeyer commented on July 25, 2024

Sorry, I just realised that the rest of the component's types are included in the pull request. Nevermind!!

from highcharts-react.

JonasGilg avatar JonasGilg commented on July 25, 2024

@JannesMeyer in which pull request? #36 was rejected and closed.

from highcharts-react.

JonasGilg avatar JonasGilg commented on July 25, 2024

Thank you, that was the answer that I think we all wanted. 🙂

from highcharts-react.

bre1470 avatar bre1470 commented on July 25, 2024

No there is no ETA for this yet, because development has not started. First the Highcharts declerations have to be stable and generally available.

from highcharts-react.

bre1470 avatar bre1470 commented on July 25, 2024

I expect though that the support will be quite fast implemented, once the Highcharts declarations are leaving the beta state.

from highcharts-react.

jonfreedman avatar jonfreedman commented on July 25, 2024

@bre1470 thanks - my understanding for now is that I should follow the instructions @ https://github.com/highcharts/highcharts-declarations-beta plus the types from @BrandonWilliamsCS updated to use your beta types e.g.
Highcharts.ChartObject -> Highcharts.Chart
highcharts?: Highcharts.Static; -> highcharts?: typeof Highcharts;
Is that fair?

from highcharts-react.

bre1470 avatar bre1470 commented on July 25, 2024

@jonfreedman Yes, that sounds reasonable and should help in the meantime.

I just like to point out, that the beta of the Highcharts declarations is not intended for regular development use. You might have to change some code after a future beta update.

from highcharts-react.

jonfreedman avatar jonfreedman commented on July 25, 2024

Happy to change later but the good news is this is working right now.

from highcharts-react.

pdeva avatar pdeva commented on July 25, 2024

now that Highcharts 7 contains typescript definitions by default, any updates on this issue?

from highcharts-react.

pdeva avatar pdeva commented on July 25, 2024
declare module "highcharts-react-official" {
    import * as React from "react";
    import * as Highcharts from "highcharts";

    /**
     * Represents a "constructor" function for a ChartObject.
     * Not technically a constructor, as it's not called with `new`.
     */
    type Constructor = (
        renderTo: HTMLElement,
        options: Highcharts.Options,
    ) => Highcharts.ChartObject;
    /**
     * Represents all of the strings that are keys of T that map to a Constructor function.
     */
    type ConstructorName<T> = {
        [K in keyof T]: T[K] extends Constructor ? K : never
    }[keyof T];

    export interface HighchartsReactProps<TContainerProps = {}> {
        highcharts?: Highcharts.Static;
        constructorType?: ConstructorName<Highcharts.Static>;
        update?: boolean;
        options: Highcharts.Options;
        containerProps?: TContainerProps;
    }
    export class HighchartsReact<TContainerProps = {}> extends React.Component<
        HighchartsReactProps<TContainerProps>
    > {}

    export default HighchartsReact;
}

@BrandonWilliamsCS this no longer works with Highcharts 7.
getting error saying Highcharts.ChartObject and Highcharts.Static do not exist

from highcharts-react.

BrandonWilliamsCS avatar BrandonWilliamsCS commented on July 25, 2024

@pdeva, Unfortunately, I don't use this actively use library any longer, so it won't be likely that I'll be taking a close look at v7.
It could be that there are other types that can be swapped in for Highcharts.ChartObject and Highcharts.Static, but it's also possible that v7 came with enough of an API change that the types I wrote are essentially incompatible.

from highcharts-react.

ppotaczek avatar ppotaczek commented on July 25, 2024

The TypeScript declarations for this wrapper have been added in verion 2.1.0.

Please report in case of any problems.

Best regards!

from highcharts-react.

jonfreedman avatar jonfreedman commented on July 25, 2024

I am seeing the following error:

node_modules/highcharts-react-official/dist/highcharts-react.min.d.ts
(51,29): An index signature parameter type must be 'string' or 'number'.

See https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.9.4

from highcharts-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.