fix(ivy): use any for generic context checks when !strictTemplates (#34649)

Previously, the template type-checker would always construct a generic
template context type with correct bounds, even when strictTemplates was
disabled. This meant that type-checking of expressions involving that type
was stricter than View Engine.

This commit introduces a 'strictContextGenerics' flag which behaves
similarly to other 'strictTemplates' flags, and switches the inference of
generic type parameters on the component context based on the value of this
flag.

PR Close #34649
This commit is contained in:
Alex Rickabaugh
2019-12-19 17:09:56 -08:00
committed by Andrew Kushnir
parent cb11380515
commit 0c8d085666
9 changed files with 61 additions and 8 deletions

View File

@ -504,6 +504,7 @@ export class NgtscProgram implements api.Program {
// Pipes are checked in View Engine so there is no strictness flag.
checkTypeOfPipes: true,
strictSafeNavigationTypes: strictTemplates,
useContextGenericType: strictTemplates,
};
} else {
typeCheckingConfig = {
@ -521,6 +522,7 @@ export class NgtscProgram implements api.Program {
checkTypeOfNonDomReferences: false,
checkTypeOfPipes: false,
strictSafeNavigationTypes: false,
useContextGenericType: false,
};
}
@ -549,6 +551,9 @@ export class NgtscProgram implements api.Program {
if (this.options.strictAttributeTypes !== undefined) {
typeCheckingConfig.checkTypeOfAttributes = this.options.strictAttributeTypes;
}
if (this.options.strictContextGenerics !== undefined) {
typeCheckingConfig.useContextGenericType = this.options.strictContextGenerics;
}
// Execute the typeCheck phase of each decorator in the program.
const prepSpan = this.perfRecorder.start('typeCheckPrep');