Typings problem

Tis is my first post here so let me tell you - I’m in love with your product. Thank you!

I have a problem, though. We develop our app using Pro version and we’re stuck on problems with the typings.
I read this topic: Property does not exist, using Angular 4 since I’m struggling with same exact issue.

My question is: are those types fixed now? If not - when can we suspect a bugfix?
We can’t afford disabling types checking by settings gantt to any type. It is considered anti-pattern and is not allowed in our firm.

Reagrds,
Marcn

Hello Marcin,
Thank you for the positive feedback.

Starting from the 6.1.0 version, the types are included in the Gantt package:
https://docs.dhtmlx.com/gantt/whatsnew.html#61

It can be that some types are missing as it was reported that there is no type for the gantt.$task property, but mostly, Gantt should have all the necessary types included. If you encounter that issue, please report about it and I will inform the dev team.

If you had 6.0.x or lower version and then you install the 6.1.0 or newer version, you will encounter another issue, now with the duplicate types. To fix it, you need to apply the following command:

npm uninstall @types/dhtmlxgantt -save-dev

And make sure that the types in the tsconfig.app.json file don’t contain "dhtmlxgantt":

    "types": [
      "dhtmlxgantt"
]

Hello @ramil

thank you for you reply and detailed explanation. Can I report missing typings here in this thread?

I am using version 6.1.7 (since 6.1.7, so no upgrade needs to be performed).
The problem is that following code throws an error:

task.planned_start_date = gantt.date.parseDate(task.planned_start_date as string, 'xml_date');

and the error is:

Property ‘parseDate’ does not exist on type ‘GanttDateHelpers’. ts(2339)

As temporary workaround I’ve created following interface:

export interface FixedGanttDateHelpers extends GanttDateHelpers {
    // there are typing missing. See https://forum.dhtmlx.com/t/typings-problem/68089 for the details

    parseDate: (date: string, format: string) => Date;
}

task.planned_end_date = (gantt.date as FixedGanttDateHelpers).parseDate(task.planned_end_date as string, 'xml_date');

However, I’d like to avoid such workarounds whenever possible. Can you confirm the types for parseDate are missing or is it only problem on my local machine?

Regards,
Marcin

Hello Marcin,
Yes, you can report the missing types here. Recently, it was discovered that the 6.2.0 version has some missing types. So, if you share the missing types, I will forward that information to the dev team, and they will add the types.

However, there is no missing type for the planned_start_date property. It is a custom property (although it is used in our examples), so it wasn’t included in the official types. You can add more properties to the task object, and Gantt will continue working correctly with that, but Angular will tell you that the type is missing, so you will need to add it.

Hello @ramil,

I think I have mislead you giving too much context, sorry about that. planned_start_date works fine for me.

Missing type is for parseDate method on gantt.date property. See blow error I’m having in my code.

The error show up for this code:
gantt.date.parseDate( ... )

Regards,
Marcin

Hello Marcin,
Thank you for the clarification.
I updated the bug in our internal tracker.

1 Like

Hello Marcin,
I would like to inform you that the dev team added more types in the 8.0 version:
https://docs.dhtmlx.com/gantt/whatsnew.html#x6629x80x6630x:~:text=Updated%20TypeScript%20type%20definitions
https://docs.dhtmlx.com/gantt/whatsnew.html#x6629x80x6630x:~:text=Type%20definitions%20are%20updated

Now there are types for the tasks, links, grid columns, scales, extensions, and almost everything in the others category:
https://docs.dhtmlx.com/gantt/desktop__task_properties.html
https://docs.dhtmlx.com/gantt/desktop__link_properties.html
https://docs.dhtmlx.com/gantt/api__gantt_columns_config.html
https://docs.dhtmlx.com/gantt/api__gantt_scales_config.html
https://docs.dhtmlx.com/gantt/api__gantt_ext_other.html
https://docs.dhtmlx.com/gantt/api__refs__gantt_others.html

You can update to the latest version to get more features and improvements, including the better Typescript Support.

However, even if you are using the older version and don’t have plans to upgrade, you can still use the updated version of the dhtmlxgantt.d.ts file as the Gantt API is mostly the same:

There are still ways to improve, so in the future versions, the dev team will add more types for Gantt.

1 Like