feat(ivy): logical not and safe navigation operation handling in TCBs (#29698)

This commit adds support in the template type-checking engine for handling
the logical not operation and the safe navigation operation.

Safe navigation in particular is tricky, as the View Engine implementation
has a rather inconvenient flaw. View Engine checks a safe navigation
operation `a?.b` as:

```typescript
(a != null ? a!.b : null as any)
```

The type of this expression is always 'any', as the false branch of the
ternary has type 'any'. Thus, using null-safe navigation throws away the
type of the result, and breaks type-checking for the rest of the expression.

A flag is introduced in the type-checking configuration to allow Ivy to
mimic this behavior when needed.

Testing strategy: TCB tests included.

PR Close #29698
This commit is contained in:
Alex Rickabaugh
2019-04-02 13:03:42 -07:00
committed by Ben Lesh
parent 182e2c7449
commit f4c536ae36
5 changed files with 63 additions and 1 deletions

View File

@ -195,6 +195,7 @@ export class NgtscProgram implements api.Program {
applyTemplateContextGuards: true,
checkTemplateBodies: true,
checkTypeOfBindings: true,
strictSafeNavigationTypes: true,
};
const ctx = new TypeCheckContext(config, this.refEmitter !);
compilation.typeCheck(ctx);