[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report <!-- Please search GitHub for a similar issue or PR before submitting -->
[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
启用 Typescript 编译器选项strictNullChecks
时,@angular/language-service 会引发错误。
例子:
interface Foo {
bar: string;
}
@Component({
selector: 'app-foo',
templateUrl: './foo.component.html'
})
export class FooComponent {
foo?: Foo;
}
示例 1:
<app-foo *ngIf="foo" [bar]="foo.bar"></app-foo>
示例 2:
<div *ngIf="foo">{{ foo.bar }}</div>
Error: ng: The expression might be null
我希望*ngIf
断言对象不为空,因此我可以安全地使用它而不会出现任何错误。
Angular version: 5.2.2
- Node version: 8.9.1
- Platform: MacOS
- Typescript 2.6.2
我认为这是一个错误,而不是功能请求。
启用 strictNullChecks 时语言服务不可用。
最有用的评论
我认为这是一个错误,而不是功能请求。
启用 strictNullChecks 时语言服务不可用。