fix(ivy): add strictLiteralTypes to align Ivy + VE checking of literals (#35462)
Under View Engine's default (non-fullTemplateTypeCheck) checking, object and array literals which appear in templates are treated as having type `any`. This allows a number of patterns which would not otherwise compile, such as indexing an object literal by a string: ```html {{ {'a': 1, 'b': 2}[value] }} ``` (where `value` is `string`) Ivy, meanwhile, has always inferred strong types for object literals, even in its compatibility mode. This commit fixes the bug, and adds the `strictLiteralTypes` flag to specifically control this inference. When the flag is `false` (in compatibility mode), object and array literals receive the `any` type. PR Close #35462
This commit is contained in:

committed by
Miško Hevery

parent
a61fe4177f
commit
4253662231
@ -121,6 +121,7 @@ In case of a false positive like these, there are a few options:
|
||||
|`strictOutputEventTypes`|Whether `$event` will have the correct type for event bindings to component/directive an `@Output()`, or to animation events. If disabled, it will be `any`.|
|
||||
|`strictDomEventTypes`|Whether `$event` will have the correct type for event bindings to DOM events. If disabled, it will be `any`.|
|
||||
|`strictContextGenerics`|Whether the type parameters of generic components will be inferred correctly (including any generic bounds). If disabled, any type parameters will be `any`.|
|
||||
|`strictLiteralTypes`|Whether object and array literals declared in the template will have their type inferred. If disabled, the type of such literals will be `any`.|
|
||||
|
||||
|
||||
If you still have issues after troubleshooting with these flags, you can fall back to full mode by disabling `strictTemplates`.
|
||||
|
Reference in New Issue
Block a user