`DHX Scheduler not found`

Currently, I am delving into VueJs 3 with TypeScript and the composition API.

I stumbled upon a helpful tutorial on integrating the scheduler in VueJs.

However, it doesn't cover all aspects that apply to my specific situation, leading to some difficulties.

More precisely, I have encountered the following error message:

scheduler is not defined

In the mentioned tutorial comments, they suggest using:

/*global scheduler*/
import 'dhtmlx-scheduler'

Despite this, the scheduler remains inaccessible, triggering the error:

TS2304: Cannot find name 'scheduler'.

My IDE recommends importing it as follows:

import { scheduler } from 'dhtmlx-scheduler'

Yet, even after implementing this suggestion, the scheduler remains undefined.

Answer №1

If you want to integrate dhtmlx-scheduler with TypeScript, remember to import both dhtmlx-scheduler and the SchedulerStatic type:

import 'dhtmlx-scheduler'
import { SchedulerStatic } from 'dhtmlx-scheduler'

This will allow you to access window.scheduler as shown below:

const scheduler: SchedulerStatic = (window as any).scheduler
scheduler.init(/*...*)

Check out this TypeScript SFC example based on the documentation:

<template>
  <div ref="scheduler"></div>
</template>

<script lang="ts"&g>.
import { defineComponent } from 'vue'
import 'dhtmlx-scheduler'
import { SchedulerStatic } from 'dhtmlx-scheduler'

export default defineComponent({
  name: 'scheduler',
  props: {
    events: {
      type: Array,
      default: () => []
    }
  },
  mounted() {
    const scheduler: SchedulerStatic = (window as any).scheduler // eslint-disable-line
    scheduler.skin = 'material'
    scheduler.config.header = [
        'day',
        'week',
        'month',
        'date',
        'prev',
        'today',
        'next'
    ]

    scheduler.init(this.$refs.scheduler as HTMLElement, new Date(2020, 0, 20), 'week')
    scheduler.parse(this.$props.events)
  }
})
</script>

<style>
@import "~dhtmlx-scheduler/codebase/dhtmlxscheduler_material.css";
</style>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why do I keep receiving a <prototype> object for each API request?

Currently, I am utilizing JSONPlaceholder in conjunction with Angular as part of my learning process. While I have been following the documentation meticulously and obtaining the correct output, there seems to be an additional element accompanying each obj ...

Following an update, the functioning of Visual Studio Tools for Apache Cordova ceases to operate accurately

Currently working on an ionic application using Visual Studio Tools for Apache Cordova, everything was going smoothly until I decided to update the Tools for Apache Cordova and TypeScript Tools for Visual Studio. Following the update, the Ripple emulator s ...

What causes TypeScript to generate an error when using two array of object types, but not when using the shape of both?

There are two basic types of data available: type DataA = { percent: string; exchange: string; }; type DataB = { price: number; exchange: string; }; I'm puzzled as to why TypeScript gives errors when I try to use both types together: const ...

What is the best way to leverage *ngIf within the host of my Directive?

I am working on creating a custom Directive that can dynamically add or remove itself from the DOM similar to *ngIf functionality. Here is what I have so far: @Directive({ selector: '[myDirective]', host: { '[hidden]': ...

parsing a TypeScript query

Is there a simpler way to convert a query string into an object while preserving the respective data types? Let me provide some context: I utilize a table from an external service that generates filters as I add them. The challenge arises when I need to en ...

Setting line chart data for Chart.js

Can you help me troubleshoot an issue I'm facing with creating a dataset for a line chart in Chart.js? Despite having an array of objects, the dataset isn't rendering correctly and I end up with two line charts instead of one. What could be causi ...

Ways to activate a click event using typescript

Having trouble getting the click event to trigger in TypeScript. I have a table with a div inside it. Initially, the table data is not loading correctly. However, manually clicking on the table refreshes the data. How can I programmatically trigger the cli ...

Vue is currently running in development mode. Please note that both $attrs and $listeners are set as readonly variables

Encountering an unusual issue with Vue 2, I have faced this problem a couple of times before and resolved it by identifying the culprit that was importing another instance/version of Vue to eliminate the $attrs/$listeners warnings. Recently, I decided to ...

"Enhance your Vue 3 experience with a stylish Instagram Feed featuring

Struggling to retrieve the most recent Instagram posts from a feed using Vue 3 and Axios due to Instagram's strict-origin-when-cross-origin policy causing constant blocks. All access tokens are properly configured. The Instagram Basic Display API gui ...

What is the reason that the protected keyword is not retained for abstract properties in TypeScript?

I'm uncertain whether this issue in TypeScript is a bug or intended functionality. In my Angular project, I have 3 classes - an abstract service, a service that implements the abstract service, and a component that utilizes the implementing service. ...

Vue/Vite vanilla setup encountering a 'Failed to fetch dynamically imported module' TypeError

We're currently working with a vanilla Vue/Vite setup and I'm encountering the error message TypeError: Failed to fetch dynamically imported module in Sentry logs. It appears that these errors coincide with new deployments to production, but I d ...

Strategies for implementing searchbar filtering in Ionic3 and Angular5 data manipulation

I'm having trouble displaying product names on my search.html page based on the search bar input. I've tried using the Ionic searchbar component but it's not working. Can anyone help me with this issue? If there's an alternative solutio ...

The V-Model is failing to bind with the jQuery mask

Currently, I have a form that uses v-model for phone input along with a mask library. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js" type="text/javascript"></script> <input type="tex ...

Creating a ref in React with TypeScript to access the state of a child component

Is there a way to access the state of a child component within the parent component without using handlers in the child or lifting the state up in the parent? How can I utilize refs in React with TypeScript to createRef and retrieve the child's state ...

Exported Members or Node Modules are not available

Starting out with Angular 2 / Typescript and following the 5 Minute Quickstart guide located here. I've come across a common issue, but with a slight twist. I'm running into several "No Exported Member" problems. For example: In app.module.ts: ...

An issue arises following an upgrade in Angular from version 9 to version 10, where the property 'propertyName' is being utilized before it has been initialized

I've spent time looking on Google, Github, and Stackoverflow for a solution to this error, but I'm still struggling to fix it. Can anyone offer a suggestion or help? Recently, I upgraded my Angular project from version 9 to version 10, and after ...

Simple method for wrestling with objects in TypeScript HTTP POST responses

Can anyone help me understand how to extract information from an object received through an HTTP POST request? Below is the code I am using: this.http.post(url, user, httpOptions).subscribe(result => { console.log(result.status); }); The issue aris ...

Leverage and implement a reusable class in Typescript

In a React Typescript project, I am facing a challenge. I want to utilize a base class component and add an additional property to its State. After attempting to modify the class from class ErrorBoundaryW extends PureComponent<any, State> {...} to ...

Encountering issues with TypeScript class

I am facing an issue with transpiling the following TypeScript class: class DataService { styles: Object[]; selectedStyle: Object; selectedChildStyle: Object; constructor() { this.styles = [{ "name": " ...

Technique in CSS/SASS to repair a div

Seeking a solution for fixing divs with text in CSS. I am aware of the background-attachment: fixed; property which creates a fancy effect. Is there a similar property to "fix" divs with text or how can this be achieved in Typescript? Your insight would be ...