ts Property 'filter' does not exist on type '{}'

typescript property getter
typescript getter/setter best practice
typescript initialize class object
typescript default constructor
typescript decorators
typescript override method
typescript abstract class
what does " function f(l: number, w: number){} " demonstrate?

I'm trying to follow Angular Material guide to create a custom filter for autocomplete input text

https://material.angular.io/components/autocomplete/overview

This is what I have

TS

import { Component, OnInit } from '@angular/core';
import { TemplateRef } from '@angular/core';
import { FormControl } from "@angular/forms";
import { Observable } from "rxjs";
import { map, startWith, filter } from 'rxjs/operators';

(...)

export class AppComponent implements OnInit {
  title = 'Your Profile';
  displayedColumns: string[] = ['selected', 'name', 'description', 'pnr'];
  dataSource = ELEMENT_DATA;

  myControl = new FormControl();
  options: any[] = ['One', 'Two', 'Three'];
  filteredOptions: Observable<string[]>;

  ngOnInit() {
     this.filteredOptions = this.myControl.valueChanges
      .pipe(
        startWith(''),
        map(value => this._filter(value))
      );
  }

  private _filter(value: any): string[] {
    const filterValue = value.toLowerCase();

    return this.options.filter(option =>   option.toLowerCase().includes(filterValue));
  }
}

HTML

<mat-form-field class="full-with-field" hintLabel="(or code)"> 
    <input matInput placeholder="RP oficina/Nombre empresa" [formControl]="companyControl" [matAutocomplete]="auto">
    <mat-autocomplete #auto="matAutocomplete"> 
        <mat-option *ngFor="let option of filteredOptions | async" [value]="option">
        {{option}} 
        </mat-option> 
    </mat-autocomplete> 
</mat-form-field>

And I'm having an error in the return sentece, the only error I get is

[ts] Property 'filter' does not exist on type '{}'.

As you can see, options is part of an array so I don't know what could happen.

When I'm debugging in Firefox I get the next error message:

Uncaught Error: Template parse errors:
Can't bind to 'formControl' since it isn't a known property of 'input'. ("="(or code)"> <input
                            matInput placeholder="RP oficina/Nombre empresa"
                            [ERROR ->][formControl]="companyControl" [matAutocomplete]="auto">
                        <mat-autocomplete #auto="matAutocompl"): ng:///AppModule/AppComponent.html@26:7
Can't bind to 'matAutocomplete' since it isn't a known property of 'input'. ("put
                            matInput placeholder="RP oficina/Nombre empresa"
                            [formControl]="companyControl" [ERROR ->][matAutocomplete]="auto">
                        <mat-autocomplete #auto="matAutocomplete"> <mat-option
                            *ngFo"): ng:///AppModule/AppComponent.html@26:38
There is no directive with "exportAs" set to "matAutocomplete" (" empresa"
                            [formControl]="companyControl" [matAutocomplete]="auto">
                        <mat-autocomplete [ERROR ->]#auto="matAutocomplete"> <mat-option
                            *ngFor="let option of filteredOptions | async" [value]=""): ng:///AppModule/AppComponent.html@27:24
Can't bind to 'value' since it isn't a known property of 'mat-option'.
1. If 'mat-option' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'mat-option' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("omplete #auto="matAutocomplete"> <mat-option
                            *ngFor="let option of filteredOptions | async" [ERROR ->][value]="option">
                        {{option}} </mat-option> </mat-autocomplete> <mat-hint align="end">Para desc"): ng:///AppModule/AppComponent.html@28:54
'mat-option' is not a known element:
1. If 'mat-option' is an Angular component, then verify that it is part of this module.
2. If 'mat-option' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("ntrol]="companyControl" [matAutocomplete]="auto">
                        <mat-autocomplete #auto="matAutocomplete"> [ERROR ->]<mat-option
                            *ngFor="let option of filteredOptions | async" [value]="option">
                        {{option}"): ng:///AppModule/AppComponent.html@27:49
'mat-autocomplete' is not a known element:
1. If 'mat-autocomplete' is an Angular component, then verify that it is part of this module.
2. If 'mat-autocomplete' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (""RP oficina/Nombre empresa"
                            [formControl]="companyControl" [matAutocomplete]="auto">
                        [ERROR ->]<mat-autocomplete #auto="matAutocomplete"> <mat-option
                            *ngFor="let option of filteredOptions "): ng:///AppModule/AppComponent.html@27:6
    at syntaxError (compiler.js:1021)
    at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:14851)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:24570)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:24557)
    at compiler.js:24500
    at Set.forEach (<anonymous>)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:24500)
    at compiler.js:24410
    at Object.then (compiler.js:1012)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:24409)
syntaxError @ compiler.js:1021
push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse @ compiler.js:14851
push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate @ compiler.js:24570
push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate @ compiler.js:24557
(anonymous) @ compiler.js:24500
push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents @ compiler.js:24500
(anonymous) @ compiler.js:24410
then @ compiler.js:1012
push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents @ compiler.js:24409
push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync @ compiler.js:24369
push../node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js.CompilerImpl.compileModuleAsync @ platform-browser-dynamic.js:143
compileNgModuleFactory__PRE_NGCC__ @ core.js:14376
push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:14559
./src/main/angular/main.ts @ main.ts:11
__webpack_require__ @ bootstrap:78
0 @ main.ts:12
__webpack_require__ @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1

Step 1.

ngOnInit() {
     this.filteredOptions = this.myControl.valueChanges
      .pipe(
        startWith(''),
        map(value => this._filter(value))
   );
}
private _filter(value: any): string[] { const filterValue = value.toLowerCase(); 
//Use the pipe 
return this.options.pipe(filter(option => option.toLowerCase().includes(filterValue)));
}

Step 2.

For the console error

When you use formControl you need to import ReactiveFormsModule Make sure you imported ReactiveFormsModule in imports array

import {FormsModule, ReactiveFormsModule} from '@angular/forms';

@NgModule({
 imports: [
   BrowserModule,
   FormsModule,
   ReactiveFormsModule,
   MaterialModule,
],

See the docs here

Property Decorators, A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use the form  TS Property Group is a team of expert builders and craftsman who work with you to determine how to renovate and customise your home for beauty and function. We are with you from concept to completion and no project is too small or too large. We design and build your project and can even stylize your home with personalised interior design.

I think you missed some importing. For Rxjs 6 try with:

import { filter } from 'rxjs/operators';

For Rxjs 5 try with:

import 'rxjs/add/operator/filter';

I suggest you to install an intellisense in your coder.

get and set in TypeScript, then the 'bar' getter for the private '_bar' property will be called. TS offers getters and setters which allow object properties to have more control of how they are  Take Shape Property Management is a property management company that provides a unique complex management solution for sectional title and full title developments. We manage complexes and buildings throughout Gauteng.

You are missing the opening [ in matAutocomplete

Template syntax, Data-binding works with properties of DOM elements, components, and directives, not HTML attributes. HTML attribute vs. DOM propertylink. The distinction  A quality property for sale in Thailand is generally offered at a fixed price by the Seller. The best benefit of using a property agent is that they will act as a liaison between you and the Seller. They will obtain a fair price for you and act on your behalf to represent your best interests throughout the entire process.

Attribute directives, src/app/app.component.ts (class) content_copy export class AppComponent { color = 'yellow'; }. Let it control the highlight color with a property binding. TS offers getters and setters which allow object properties to have more control of how they are accessed (getter) or updated (setter) outside of the object. Instead of directly accessing or updating the property a proxy function is called.

Property Management, Managing your property requires close careful attention to all of the details. We have very much enjoyed our time with TS Properties and are sad to leave due  Tennessee Property Data Home Page Real Estate Assessment Data Application. The information presented on this site is used by county Assessors of Property to assess the value of real estate for property tax purposes. Data on this site exists for 84 of Tennessee's 95 counties.

Thomas Stafford Properties, Inc., Thomas Stafford Properties, Inc. specializes in the sales and management of residential Real Estate property in the Bay Area. Our main focus is the East Bay. Eastern House Apartments provide serviced accommodation in Beijing 26 kilometres from Beijing Capital International Airport and a 16 minute walk from the nearest subway station. On-site parking is available at the property for an additional charge.

Comments
  • Oh sorry I forgot to put the imports in the question. The filter import was already added but nothing happens.
  • I don't know how it happened but this is a typo in the question code (since I edited some texts from original code)
  • This is a different error altogether. Have a look at this stackoverflow.com/a/53268299/6019563