diff --git a/src/material/form-field/form-field.ts b/src/material/form-field/form-field.ts index 77facad49326..e6362cd0ba68 100644 --- a/src/material/form-field/form-field.ts +++ b/src/material/form-field/form-field.ts @@ -46,7 +46,7 @@ import {MAT_PREFIX, MatPrefix} from './directives/prefix'; import {MAT_SUFFIX, MatSuffix} from './directives/suffix'; import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import {matFormFieldAnimations} from './form-field-animations'; -import {MatFormFieldControl} from './form-field-control'; +import {MatFormFieldControl as _MatFormFieldControl} from './form-field-control'; import { getMatFormFieldDuplicatedHintError, getMatFormFieldMissingControlError, @@ -118,6 +118,16 @@ const DEFAULT_SUBSCRIPT_SIZING: SubscriptSizing = 'fixed'; */ const FLOATING_LABEL_DEFAULT_DOCKED_TRANSFORM = `translateY(-50%)`; +/** + * Despite `MatFormFieldControl` being an abstract class, most of our usages enforce its shape + * using `implements` instead of `extends`. This appears to be problematic when Closure compiler + * is configured to use type information to rename properties, because it can't figure out which + * class properties are coming from. This interface seems to work around the issue while preserving + * our type safety (alternative being using `any` everywhere). + * @docs-private + */ +interface MatFormFieldControl extends _MatFormFieldControl {} + /** Container for form controls that applies Material Design styling and behavior. */ @Component({ selector: 'mat-form-field', @@ -172,7 +182,7 @@ export class MatFormField @ContentChild(MatLabel) _labelChildNonStatic: MatLabel | undefined; @ContentChild(MatLabel, {static: true}) _labelChildStatic: MatLabel | undefined; - @ContentChild(MatFormFieldControl) _formFieldControl: MatFormFieldControl; + @ContentChild(_MatFormFieldControl) _formFieldControl: MatFormFieldControl; @ContentChildren(MAT_PREFIX, {descendants: true}) _prefixChildren: QueryList; @ContentChildren(MAT_SUFFIX, {descendants: true}) _suffixChildren: QueryList; @ContentChildren(MAT_ERROR, {descendants: true}) _errorChildren: QueryList; diff --git a/tools/public_api_guard/material/form-field.md b/tools/public_api_guard/material/form-field.md index dacc8f35735d..d749e28d831a 100644 --- a/tools/public_api_guard/material/form-field.md +++ b/tools/public_api_guard/material/form-field.md @@ -74,8 +74,8 @@ export class MatFormField implements FloatingLabelParent, AfterContentInit, Afte get appearance(): MatFormFieldAppearance; set appearance(value: MatFormFieldAppearance); color: ThemePalette; - get _control(): MatFormFieldControl; - set _control(value: MatFormFieldControl); + get _control(): MatFormFieldControl_2; + set _control(value: MatFormFieldControl_2); // (undocumented) _elementRef: ElementRef; // (undocumented) @@ -86,7 +86,7 @@ export class MatFormField implements FloatingLabelParent, AfterContentInit, Afte set floatLabel(value: FloatLabelType); _forceDisplayInfixLabel(): boolean | 0; // (undocumented) - _formFieldControl: MatFormFieldControl; + _formFieldControl: MatFormFieldControl_2; getConnectedOverlayOrigin(): ElementRef; _getDisplayedMessages(): 'error' | 'hint'; getLabelId(): string | null;