diff --git a/packages/compiler-cli/src/diagnostics/expression_type.ts b/packages/compiler-cli/src/diagnostics/expression_type.ts index 72be38975e..cdecaa0f7d 100644 --- a/packages/compiler-cli/src/diagnostics/expression_type.ts +++ b/packages/compiler-cli/src/diagnostics/expression_type.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {AST, AstVisitor, Binary, BindingPipe, Chain, Conditional, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, visitAstChildren} from '@angular/compiler'; +import {AST, AstVisitor, Binary, BindingPipe, Chain, Conditional, FunctionCall, ImplicitReceiver, Interpolation, KeyedRead, KeyedWrite, LiteralArray, LiteralMap, LiteralPrimitive, MethodCall, NonNullAssert, PrefixNot, PropertyRead, PropertyWrite, Quote, SafeMethodCall, SafePropertyRead, visitAstChildren} from '@angular/compiler'; import {BuiltinType, Signature, Span, Symbol, SymbolQuery, SymbolTable} from './symbols'; @@ -283,6 +283,11 @@ export class AstType implements AstVisitor { return this.query.getBuiltinType(BuiltinType.Boolean); } + visitNonNullAssert(ast: NonNullAssert) { + const expressionType = this.getType(ast.expression); + return this.query.getNonNullableType(expressionType); + } + visitPropertyRead(ast: PropertyRead) { return this.resolvePropertyRead(this.getType(ast.receiver), ast); } diff --git a/packages/compiler-cli/test/diagnostics/expression_diagnostics_spec.ts b/packages/compiler-cli/test/diagnostics/expression_diagnostics_spec.ts index 518e117cfa..db2ceceacd 100644 --- a/packages/compiler-cli/test/diagnostics/expression_diagnostics_spec.ts +++ b/packages/compiler-cli/test/diagnostics/expression_diagnostics_spec.ts @@ -135,6 +135,8 @@ describe('expression diagnostics', () => { () => reject(`