Back to Fullcalendar

TypeScript Support

_docs-v5/third-party/typescript.md

latest1.4 KB
Original Source

It is possible to use FullCalendar and Scheduler with TypeScript, a type-aware superset of the JavaScript language that compiles down to JavaScript.<!--more--> TypeScript is great for the maintainability of large JavaScript projects, however, it is probably overkill for smaller projects. Learn more about TypeScript »

You will then need to set up some sort of build system that compiles TypeScript to JavaScript. You can use the tsc compiler directly or you can use a more sophisticated system like Webpack.

Once you have your build system set up, you can begin to write type-aware code like this:

example.ts:

ts
import { Calendar } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';

document.addEventListener('DOMContentLoaded', function() {
  let calendarEl: HTMLElement = document.getElementById('calendar')!;

  let calendar = new Calendar(calendarEl, {
    plugins: [ dayGridPlugin ]
    // options here
  });

  calendar.render();
});