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.