fix(compiler-cli): produce diagnostic messages in expression of PrefixNot node. (#33087)

PR Close #33087
This commit is contained in:
Andrius 2019-10-10 19:07:48 +03:00 committed by Miško Hevery
parent f54adf10b5
commit 2ddc851090
2 changed files with 7 additions and 0 deletions

View File

@ -304,6 +304,10 @@ export class AstType implements AstVisitor {
} }
visitPrefixNot(ast: PrefixNot) { visitPrefixNot(ast: PrefixNot) {
// If we are producing diagnostics, visit the children
if (this.diagnostics) {
visitAstChildren(ast, this);
}
// The type of a prefix ! is always boolean. // The type of a prefix ! is always boolean.
return this.query.getBuiltinType(BuiltinType.Boolean); return this.query.getBuiltinType(BuiltinType.Boolean);
} }

View File

@ -98,6 +98,9 @@ describe('expression diagnostics', () => {
() => reject( () => reject(
'<div *ngIf="persson">{{person.name.first}}</div>', '<div *ngIf="persson">{{person.name.first}}</div>',
'Identifier \'persson\' is not defined')); 'Identifier \'persson\' is not defined'));
it('should reject *ngIf of misspelled identifier in PrefixNot node',
() =>
reject('<div *ngIf="people && !persson"></div>', 'Identifier \'persson\' is not defined'));
it('should accept an *ngFor', () => accept(` it('should accept an *ngFor', () => accept(`
<div *ngFor="let p of people"> <div *ngFor="let p of people">
{{p.name.first}} {{p.name.last}} {{p.name.first}} {{p.name.last}}