[ ] 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.