Hi. I’m using vite, and react+ts.
I’m able to develop just fine, and also build without errors.
But, after opening a page using dhtmlx-gantt, I get this error:
TypeError: Cannot read properties of undefined (reading ‘config’)
Here’s my package.json entry:
"dhtmlx-gantt": "file:gantt_8.0.9_startup",
Here’s my vite.config.ts:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
optimizeDeps: {
include: ["dhtmlx-gantt"],
},
});
Here’s my tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src", "gantt_8.0.9_startup"],
"exclude": ["tests"],
"references": [{ "path": "./tsconfig.node.json" }]
}
And finally here’s how I’m using it in my code:
import * as dhtmlxGantt from "dhtmlx-gantt";
const { gantt } = dhtmlxGantt;
type GanttTask = dhtmlxGantt.Task & {
serverTask: ScheduleTaskDTO;
};
// then, I'm using it like
gantt.config.xxx = yyyy
Can you please help me?