2
votes

Using angular-material schematic, I want to generate the navigation menu. For that I use the following command:

ng generate @angular/material:material-nav --name layout

When I serve my application, this error is thrown:

error TS2322: Type 'Observable' is not assignable to type 'Observable'. Type 'boolean' is not assignable to type 'BreakpointState'.

2
github.com/angular/angular-cli/issues/10960 I think, you should check this issue.Lafexlos
As I see, the issue is still openedkeveked
There is a PR that fixes this issue but not sure when it'll be merged. Maybe until that time, you can manually fix it.Lafexlos

2 Answers

3
votes

Adding an answer just to make this remove from unanswered ones.

This is a known issue and fixed by this pull request.

Until this PR goes live, you can make changes manually.

__name@dasherize__.component.html

From:

[attr.role]="isHandset$ | async ? 'dialog' : 'navigation'"
[mode]="isHandset$ | async ? 'over' : 'side'"

To:

[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"

__name@dasherize__.component.ts

From:

[attr.role]="isHandset$ | async ? 'dialog' : 'navigation'"
[mode]="isHandset$ | async ? 'over' : 'side'"

To:

[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"

From:

isHandset$: Observable<BreakpointState> = this.breakpointObserver.observe(Breakpoints.Handset)

To:

isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
1
votes

Just change type of observable to boolean in your typescript file. Match parentheses in your component html file [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'" [mode]="(isHandset$ | async) ? 'over' : 'side'"

here is the fix in Green Lines

enter image description here

Here is the main link of fix-https://github.com/angular/material2/pull/11448/commits/20306dbeed3fe7232ffb85ba1d9fd406f6885db2