quasarframework / quasar-ui-qcalendar

QCalendar - Quasar App Extension, Vue CLI plug-in and UMD distributions available
https://quasarframework.github.io/quasar-ui-qcalendar
MIT License
421 stars 116 forks source link

fix(ui): use correct type definitions for createNativeLocaleFormatter… #440

Open ptoal opened 1 month ago

ptoal commented 1 month ago

This addresses typescript compiling errors when using the createNativeLocaleFormatter function per the examples in the documentation. The return type of this function is a function, not a string.

Tested this fix on my project, which uses the following snippets of code (taken from docs/src/examples/DayCustomHeader.vue):

<div style="width: 100%; font-size: 0.9em">
   {{ monthFormatter(day, true) }}
</div>

const  monthFormatter = monthFormatterFunc(),

function monthFormatterFunc() {
  const longOptions: Intl.DateTimeFormatOptions = {
    timeZone: 'UTC',
    month: 'long',
  };
  const shortOptions: Intl.DateTimeFormatOptions = {
    timeZone: 'UTC',
    month: 'short',
  };

  return createNativeLocaleFormatter(locale.value, (_tms, short) =>
    short ? shortOptions : longOptions
  );
}```
… (#439)