tabuckner / material-dayjs-adapter

A MatDateAdapter for Dayjs
https://www.npmjs.com/package/@tabuckner/material-dayjs-adapter
15 stars 23 forks source link

Uncaught TypeError: Class extends value undefined is not a constructor or null #30

Open danwellman opened 3 years ago

danwellman commented 3 years ago

I'm using:

I'm working with an established and large application which is using an Angular Material datepicker with Moment.js (and momentjs date adapter). This is used in many, many places throughout the application, and Moment is also used independently for doing various date formatting/calculation outside of the date-picker. For consistency we have a simple date-component which wraps the material date-picker and sets some config, so that the picker can be used around the application with minimal effort.

So now I would like to use dayjs instead of momentjs with the material date-picker. I've created a new wrapper component for the date-picker and in the module I've imported the MatDayjsDateModule as shown here: https://www.npmjs.com/package/@tabuckner/material-dayjs-adapter

However, even before actually using my wrapper component anywhere in the application, I'm seeing an error in the console when serving the application:

Uncaught TypeError: Class extends value undefined is not a constructor or null at Module.euac (tabuckner-material-dayjs-adapter.js:63)

Could this be due to the fact that I am still using Momentjs in the old wrapper component? Is it possible to use both Momentjs and Dayjs in the same application?

Obviously I can't include my full repo as it's a closed commercial application. The module for my wrapper component is as follows:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatDayjsDateModule } from '@tabuckner/material-dayjs-adapter';

import { DatePickerComponent } from './date-picker.component';

@NgModule({
  imports: [CommonModule, ReactiveFormsModule, MatDatepickerModule, MatDayjsDateModule],
  declarations: [DatePickerComponent],
  exports: [DatePickerComponent, MatDayjsDateModule],
})
export class DatePickerModule {}

Any idea what could be causing the issue?

aceleghin commented 3 years ago

Same here without moment.

TevaLautier commented 3 years ago

I have same issue It seems that it comes from : DayjsDateAdapter extends DateAdapter
instead of DayjsDateAdapter extends DateAdapter < DayJs >

It means that this package is not compatible with angular 10 import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material'; instead of import { DateAdapter, MAT_DATE_LOCALE } from '@angular/material/core';