-
Notifications
You must be signed in to change notification settings - Fork 26.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve host binding type issues #60481
Conversation
@@ -279,7 +274,8 @@ export interface ImagePlaceholderConfig { | |||
'[style.background-position]': 'placeholder ? "50% 50%" : null', | |||
'[style.background-repeat]': 'placeholder ? "no-repeat" : null', | |||
'[style.background-image]': 'placeholder ? generatePlaceholder(placeholder) : null', | |||
'[style.filter]': `placeholder && shouldBlurPlaceholder(placeholderConfig) ? "blur(${PLACEHOLDER_BLUR_AMOUNT}px)" : null`, | |||
'[style.filter]': | |||
'placeholder && shouldBlurPlaceholder(placeholderConfig) ? "blur(15px)" : null', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the string interpolation here, because it was preventing type checking. It also seemed like it was there purely for the unit tests.
@@ -687,7 +683,7 @@ export class NgOptimizedImage implements OnInit, OnChanges { | |||
* * A base64 encoded image, which is wrapped and passed through. | |||
* * A boolean. If true, calls the image loader to generate a small placeholder url. | |||
*/ | |||
private generatePlaceholder(placeholderInput: string | boolean): string | boolean | null { | |||
protected generatePlaceholder(placeholderInput: string | boolean): string | boolean | null { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These had to be made protected
, because it's not allowed to use private methods in templates/host bindings.
@@ -46,7 +46,7 @@ const CHECKBOX_VALUE_ACCESSOR: Provider = { | |||
@Directive({ | |||
selector: | |||
'input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]', | |||
host: {'(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()'}, | |||
host: {'(change)': 'onChange($any($event.target).checked)', '(blur)': 'onTouched()'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are cast to any
, because $event.target
is an EventTarget
and we have no way of casting it to HTMLInputElement
. The other option we be to have a type assertion in a separate method, but I didn't want to add more runtime code here.
e305e2e
to
6d83cbf
Compare
c27cef3
to
25d60e4
Compare
Enables strict templates and type checking of host bindings against our own code.
Fixes type checking issues in the dev tools that weren't showing up, because we had `strictTemplates` turned off.
Fixes type issues in the host bindings of `NgOptimizedImage`.
Fixes some type issues that are being flagged now that we have type checking of host bindings.
Resolves typing issues inside host binding in adev.
Fixes some type checking issues in our own testing code that weren't showing up, because `strictTemplates` was turned off.
25d60e4
to
4d6d1cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed-for: public-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reviewed-for: public-api
This PR was merged into the repository by commit 911ad40. The changes were merged into the following branches: main |
Fixes type checking issues in the dev tools that weren't showing up, because we had `strictTemplates` turned off. PR Close #60481
Fixes type issues in the host bindings of `NgOptimizedImage`. PR Close #60481
Fixes some type issues that are being flagged now that we have type checking of host bindings. PR Close #60481
Resolves typing issues inside host binding in adev. PR Close #60481
Fixes some type checking issues in our own testing code that weren't showing up, because `strictTemplates` was turned off. PR Close #60481
Updates our build setup to type check host bindings in our own directives, and fixes any pre-existing issues. This is a prerequisite for enabling the new type checking internally.