TS declaration file recurrence.d.ts is not being exported correctly

I’m using Angular v14 and Mobiscroll v5.17.0.

The TS declaration file “recurrence.d.ts” under “@mobiscroll/angular/dist/js/core/util/recurrence” is not being exported correctly and this forces users using mobiscroll to write the full path of the file when importing it.

For example if I want to import the MbscCalendarEvent interface, I can easily do it, by wirtting the following:

import { MbscCalendarEvent } from '@mobiscroll/angular';

But if I want to import the MbscRecurrenceRule interface, I have to write:

import { MbscRecurrenceRule } from '@mobiscroll/angular/dist/js/core/util/recurrence';

It would be nice to be able to import the MbscRecurrenceRule interface by only specifying “@mobiscroll/angular”.

Hi Josep,

I’m forwarding this to the product team and I will get back to you as soon as we make progress on it.
Also, could you share a little bit about the context where this would be used?

Hi Gabi!

Thanks for answering fast.

Well the context is not much, but basically there is sometimes the need to import interfaces from Mobiscroll for typing things in TypeScript.

Imagine for example some function like the following (it’s an example):

export function getCalendarRecurrenceRuleFromBackEndRecurrenceRule(
    recurrenceRule: BackEndRecurrenceRule,
): MbscRecurrenceRule {
    // Some code here that maps the recurrence rule defined in the dataabase
    // to a recurrence rule that Mobiscroll can understand

One normally defines the models in the Database decoupled from the libraries used in the Front End.

So in the Front End, one needs to map this models to what it’s needed to display them in the UI.

There is also other cases, where you may know that you are going to work with recurrence rules of type object (not a string), and maybe you want to write something like this:

// Imagine that "event" is of type "MbscCalendarEventData"
const recurrenceRule = event.original.recurring as MbscRecurrenceRule | undefined

Keep in mind that the code above is not a good practice, the correct way would be to check if the recurring rule is really an object by using the typeof operator:

const recurrenceRule = event.original.recurring;

if (recurrenceRule !== undefined && typeof recurrenceRule !== 'string') {
   // Now one can safely assume that the recurrence rule is an 
   // object of type MbscRecurrenceRule

Having said that, independently if there are use cases or not, I think that it would give better developer experience to be able to import any interface that is part of the public API of Mobiscroll from the same path @mobiscroll/angular.

MbscRecurrenceRule is part of the public API because I can read and write the recurrence rule of an event.

In my opinion, where the interface MbscRecurrenceRule is located, should be abstracted.

If tomorrow Mobiscroll launches the version 6.0 and changes the location of the interface MbscRecurrenceRule this should not break my application.

But the current implementation would break it because the import depends on where the interface is located in the production bundle that Mobiscroll distributes through npm.

Hello @Josep_Ponsati :wave:

Perfect, thanks for sharing!

Happy to let you know that I added your voice to a bug report.
When it’s fixed, I’ll let you know.

Hi @Josep_Ponsati :wave:

Good news: we have shipped Mobiscroll 5.17.2, where we added an export for the MbscRecurrenceRule typescript type.

Here you can find a guide of how you can update the Mobiscroll version to the latest: Update guide on the latest version of Mobiscroll for plain JS, jQuery, Angular, Ionic and React.