Typings

From version 4.2.0 Mobiscroll for Javascript comes with type definitions files, that allow better usage in typescript environments.

Installing types

Type definition files come with the extension *.d.ts and are included in every Mobiscroll package from version 4.2.0. Installing and importing the mobiscroll package makes the types available as well.

Example installing and using the types with npm:

$ npm install @mobiscroll/javascript --save

After installation the package needs to be imported into the app with the needed types:

import { mobiscroll, Calendar, MbscCalendarOptions } from '@mobiscroll/javascript'; // importing the package

Usage

// declaring the options with the type gives auto-suggest for settings
var options: MbscCalendarOptions = {
    theme: 'ios',
    calendarScroll: 'vertical'
};

// Initializing the calendar and saving the instance
var myCalendarInstance: Calendar = mobiscroll.calendar('#myID', options);

// Calling instance methods
myCalendarInstance.setVal(new Date(), true, false);
myCalendarInstance.show();