typescript error: 'RRule' only refers to a type, but is being used as a namespace here

Viewed 6691

Im trying to implement 'rrule' for my angular calendar. It's showing me an error: [ts] 'RRule' only refers to a type, but is being used as a namespace here.

import RRule from 'rrule';

interface RecurringEvent {
  title: string;
  color: any;
  rrule?: {
    freq: RRule.Frequency;
    bymonth?: number;
    bymonthday?: number;
    byweekday?: RRule.Weekday[];
  };
}
2 Answers

it's because on:

    freq: RRule.Frequency;
byweekday?: RRule.Weekday[];

you are accessing elements from RRule but you don't have an instance from this class. Here I suppose you want to get the type of those elements. You can navigate to the definition of RRule and get those types, then you must have to add their imports too.

Or it should also be possible to use something like

  freq: typeof RRule.Frequency;
  ...
Related