Search code examples
angularag-grid-angular

argument of type read: typeof elementref is not assignable to parameter of type property static is missing in type


I've created custom date filter in ag-angular-grid. This is date filter component:

import { Component, ElementRef, ViewChild } from '@angular/core';

@Component({
  selector: 'app-loading-overlay',
  template: `
        <div #flatpickrEl class="ag-input-wrapper custom-date-filter" role="presentation">
            <input type='text' data-input />
            <a class='input-button' title='clear' data-clear>
                <i class='fa fa-times'></i>
            </a>
        </div>
    `,
})

export class CustomDateFilter {
  @ViewChild("flatpickrEl", { read: typeof ElementRef }) flatpickrEl: ElementRef;
.....
}

Error is in this place: { read: typeof ElementRef }

Error is:

A wrapper around a native element inside a View.

An ElementRef is backed by a render-specific element. In browser, this is usually a DOM element.

argument of type {read: 'string' | 'number' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' } is not assignable to parameter of type { read?: any static: boolean; } Property 'static' is missing in type {read: 'string' | 'number' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function' }

Solution

  • From Angular 8 you need to provide static property in the options:

    @ViewChild("flatpickrEl", { read: typeof ElementRef, static: true | false }) flatpickrEl: ElementRef;