I'm coding along with the book *Pro Angular 9*, by Adam Freeman. Line 8 is throwing an error:

```js
private categories: string[] = [];

```

The error is

```
Error: src/app/model/product.repository.ts:13:7 - error TS2322:
Type '(string | undefined)[]' is not assignable to type 'string[]'.
  Type 'string | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.

```

I have no idea what that line means. How can a variable be a string and an array?

To confuse me further, Angular says the error is in line 13, not line 8. Here's line 13:

```js
this.categories = data.map(p => p.category).filter((c, index, array) => array.indexOf(c) == index).sort();

```

I don't know what that line does, other than run a map over an array with a filter.

The file has two more errors. Line 17:

```js
getProducts(category: string = null): Product[] {

```

```
Type 'null' is not assignable to type 'string'.

```

In JavaScript I would make an empty string: `var myString = ''`. In TypeScript why would you make a string null? Aren't `string` and `null` different types?

The third error is in line 22:

```js
return this.products.find(p => p.id == id);

```

```
Type 'Product | undefined' is not assignable to type 'Product'.
  Type 'undefined' is not assignable to type 'Product'.

```

I have no idea what that means.

Here's the entire file:

```js
import { Injectable } from "@angular/core";
import { Product } from "./product.model";
import { StaticDataSource } from "./static.datasource";

@Injectable()
export class ProductRepository {
  private products: Product[] = [];
  private categories: string[] = [];

  constructor(private dataSource: StaticDataSource) {
    dataSource.getProducts().subscribe(data => {
      this.products = data;
      this.categories = data.map(p => p.category).filter((c, index, array) => array.indexOf(c) == index).sort();
    });
  }

  getProducts(category: string = null): Product[] {
    return this.products.filter(p => category == null || category == p.category);
  }

  getProduct(id: number): Product {
    return this.products.find(p => p.id == id);
  }

  getCategories(): string[] {
    return this.categories;
  }
}

```

Here's `product.model.ts`:

```js
export class Product {

  constructor(
    public id?: number,
    public name?: string,
    public category?: string,
    public description?: string,
    public price?: number
  ) { }
}

```

That threw another error:

`Unexpected token. A constructor, method, accessor, or property was expected.`

Is the error on line 22 due to an error in the `Product` class? What's the error in the `Product` class? It looks like the class has a constructor.

I went to the book's GitHub repo and downloaded the latest files, which are the same as in the book.