fix(compiler-cli): allow '==' to compare nullable types (#16731)

Fixes: #16729

* fix(compiler-cli): diagnose issues in conditional of ternary

Fixes: #16730
This commit is contained in:
Chuck Jazdzewski
2017-05-16 16:36:51 -07:00
committed by Jason Aden
parent c805082648
commit d761059e4d
2 changed files with 37 additions and 3 deletions

View File

@ -175,7 +175,16 @@ describe('expression diagnostics', () => {
it('should reject an uncalled event handler',
() => reject(
'<div (click)="click">{{person.name.first}}</div>', 'Unexpected callable expression'));
describe('with comparisions between nullable and non-nullable', () => {
it('should accept ==', () => accept(`<div>{{e == 1 ? 'a' : 'b'}}</div>`));
it('should accept ===', () => accept(`<div>{{e === 1 ? 'a' : 'b'}}</div>`));
it('should accept !=', () => accept(`<div>{{e != 1 ? 'a' : 'b'}}</div>`));
it('should accept !==', () => accept(`<div>{{e !== 1 ? 'a' : 'b'}}</div>`));
it('should accept &&', () => accept(`<div>{{e && 1 ? 'a' : 'b'}}</div>`));
it('should accept ||', () => accept(`<div>{{e || 1 ? 'a' : 'b'}}</div>`));
it('should reject >',
() => reject(`<div>{{e > 1 ? 'a' : 'b'}}</div>`, 'The expression might be null'));
});
});
const FILES: Directory = {
@ -216,6 +225,7 @@ const FILES: Directory = {
promised_people: Promise<Person[]>;
private private_person: Person;
private private_people: Person[];
e?: number;
getPerson(): Person { return this.person; }
click() {}