Angular: @angular/language-service: support for strictNullChecks and ngIf

Created on 1 Feb 2018  ·  1Comment  ·  Source: angular/angular

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When Typescript compiler option strictNullChecks is enabled, the @angular/language-service throws errors.

Example:

image

interface Foo {
  bar: string;
}

@Component({
  selector: 'app-foo',
  templateUrl: './foo.component.html'
})
export class FooComponent {
  foo?: Foo;
}

Example 1:

<app-foo *ngIf="foo" [bar]="foo.bar"></app-foo>

Example 2:

<div *ngIf="foo">{{ foo.bar }}</div>
Error: ng: The expression might be null

Expected behavior

I expect *ngIf to assert the object not to be null, so I can safely use it without any errors.

Environment


Angular version: 5.2.2
- Node version: 8.9.1
- Platform:  MacOS
- Typescript 2.6.2
language-service feature

Most helpful comment

I would consider this as a bug, not a feature request.

The language service is unusable with strictNullChecks enabled.

>All comments

I would consider this as a bug, not a feature request.

The language service is unusable with strictNullChecks enabled.

Was this page helpful?
0 / 5 - 0 ratings