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:

committed by
Ben Lesh

parent
182e2c7449
commit
f4c536ae36
@ -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);
|
||||
|
Reference in New Issue
Block a user