Skip to content

refactor(multiple): eliminate usages of any type (batch 1) #30741

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions goldens/material/snack-bar/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ import { TemplateRef } from '@angular/core';
import { ViewContainerRef } from '@angular/core';

// @public
export const MAT_SNACK_BAR_DATA: InjectionToken<any>;
export const MAT_SNACK_BAR_DATA: InjectionToken<unknown>;

// @public
export const MAT_SNACK_BAR_DEFAULT_OPTIONS: InjectionToken<MatSnackBarConfig<any>>;
export const MAT_SNACK_BAR_DEFAULT_OPTIONS: InjectionToken<MatSnackBarConfig<unknown>>;

// @public @deprecated
export function MAT_SNACK_BAR_DEFAULT_OPTIONS_FACTORY(): MatSnackBarConfig;
Expand All @@ -48,10 +48,10 @@ export class MatSnackBar implements OnDestroy {
// (undocumented)
ngOnDestroy(): void;
open(message: string, action?: string, config?: MatSnackBarConfig): MatSnackBarRef<TextOnlySnackBar>;
get _openedSnackBarRef(): MatSnackBarRef<any> | null;
set _openedSnackBarRef(value: MatSnackBarRef<any> | null);
openFromComponent<T, D = any>(component: ComponentType<T>, config?: MatSnackBarConfig<D>): MatSnackBarRef<T>;
openFromTemplate(template: TemplateRef<any>, config?: MatSnackBarConfig): MatSnackBarRef<EmbeddedViewRef<any>>;
get _openedSnackBarRef(): MatSnackBarRef<unknown> | null;
set _openedSnackBarRef(value: MatSnackBarRef<unknown> | null);
openFromComponent<T, D = unknown>(component: ComponentType<T>, config?: MatSnackBarConfig<D>): MatSnackBarRef<T>;
openFromTemplate<C = unknown>(template: TemplateRef<C>, config?: MatSnackBarConfig): MatSnackBarRef<EmbeddedViewRef<C>>;
simpleSnackBarComponent: typeof SimpleSnackBar;
snackBarContainerComponent: typeof MatSnackBarContainer;
// (undocumented)
Expand Down Expand Up @@ -82,7 +82,7 @@ export const matSnackBarAnimations: {
};

// @public
export class MatSnackBarConfig<D = any> {
export class MatSnackBarConfig<D = unknown> {
announcementMessage?: string;
data?: D | null;
direction?: Direction;
Expand Down Expand Up @@ -174,7 +174,7 @@ export class SimpleSnackBar implements TextOnlySnackBar {
constructor(...args: unknown[]);
action(): void;
// (undocumented)
data: any;
data: TextOnlySnackBarData;
get hasAction(): boolean;
// (undocumented)
snackBarRef: MatSnackBarRef<SimpleSnackBar>;
Expand All @@ -189,16 +189,21 @@ export interface TextOnlySnackBar {
// (undocumented)
action: () => void;
// (undocumented)
data: {
message: string;
action: string;
};
data: TextOnlySnackBarData;
// (undocumented)
hasAction: boolean;
// (undocumented)
snackBarRef: MatSnackBarRef<TextOnlySnackBar>;
}

// @public
export interface TextOnlySnackBarData {
// (undocumented)
action: string;
// (undocumented)
message: string;
}

// (No @packageDocumentation comment for this package)

```
8 changes: 4 additions & 4 deletions goldens/material/stepper/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export class MatStep extends CdkStep implements ErrorStateMatcher, AfterContentI
}

// @public
export class MatStepContent {
export class MatStepContent<C = unknown> {
constructor(...args: unknown[]);
// (undocumented)
_template: TemplateRef<any>;
_template: TemplateRef<C>;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatStepContent, "ng-template[matStepContent]", never, {}, {}, never, never, true, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MatStepContent<any>, "ng-template[matStepContent]", never, {}, {}, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatStepContent, never>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatStepContent<any>, never>;
}

// @public (undocumented)
Expand Down
36 changes: 22 additions & 14 deletions goldens/material/tabs/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export const _MAT_INK_BAR_POSITIONER: InjectionToken<_MatInkBarPositioner>;
export function _MAT_INK_BAR_POSITIONER_FACTORY(): _MatInkBarPositioner;

// @public
export const MAT_TAB: InjectionToken<any>;
export const MAT_TAB: InjectionToken<MatTabBase>;

// @public
export const MAT_TAB_CONTENT: InjectionToken<MatTabContent>;
export const MAT_TAB_CONTENT: InjectionToken<MatTabContent<unknown>>;

// @public
export const MAT_TAB_GROUP: InjectionToken<any>;
export const MAT_TAB_GROUP: InjectionToken<MatTabGroupBase>;

// @public
export const MAT_TAB_LABEL: InjectionToken<MatTabLabel>;
Expand Down Expand Up @@ -143,17 +143,17 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte
}

// @public (undocumented)
export class MatTab implements OnInit, OnChanges, OnDestroy {
export class MatTab<C = unknown> implements MatTabBase, OnInit, OnChanges, OnDestroy {
constructor(...args: unknown[]);
ariaLabel: string;
ariaLabelledby: string;
bodyClass: string | string[];
// (undocumented)
_closestTabGroup: any;
_closestTabGroup: MatTabGroupBase | null;
get content(): TemplatePortal | null;
disabled: boolean;
id: string | null;
_implicitContent: TemplateRef<any>;
_implicitContent?: TemplateRef<C>;
isActive: boolean;
labelClass: string | string[];
// (undocumented)
Expand All @@ -171,9 +171,13 @@ export class MatTab implements OnInit, OnChanges, OnDestroy {
set templateLabel(value: MatTabLabel);
textLabel: string;
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<MatTab, "mat-tab", ["matTab"], { "disabled": { "alias": "disabled"; "required": false; }; "textLabel": { "alias": "label"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; }; "labelClass": { "alias": "labelClass"; "required": false; }; "bodyClass": { "alias": "bodyClass"; "required": false; }; "id": { "alias": "id"; "required": false; }; }, {}, ["templateLabel", "_explicitContent"], ["*"], true, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MatTab<any>, "mat-tab", ["matTab"], { "disabled": { "alias": "disabled"; "required": false; }; "textLabel": { "alias": "label"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; }; "labelClass": { "alias": "labelClass"; "required": false; }; "bodyClass": { "alias": "bodyClass"; "required": false; }; "id": { "alias": "id"; "required": false; }; }, {}, ["templateLabel", "_explicitContent"], ["*"], true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatTab, never>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatTab<any>, never>;
}

// @public
export interface MatTabBase {
}

// @public
Expand Down Expand Up @@ -228,18 +232,18 @@ export class MatTabChangeEvent {
}

// @public
export class MatTabContent {
export class MatTabContent<C = unknown> {
constructor(...args: unknown[]);
// (undocumented)
template: TemplateRef<any>;
template: TemplateRef<C>;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatTabContent, "[matTabContent]", never, {}, {}, never, never, true, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MatTabContent<any>, "[matTabContent]", never, {}, {}, never, never, true, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<MatTabContent, never>;
static ɵfac: i0.ɵɵFactoryDeclaration<MatTabContent<any>, never>;
}

// @public
export class MatTabGroup implements AfterViewInit, AfterContentInit, AfterContentChecked, OnDestroy {
export class MatTabGroup implements MatTabGroupBase, AfterViewInit, AfterContentInit, AfterContentChecked, OnDestroy {
constructor(...args: unknown[]);
alignTabs: string | null;
_allTabs: QueryList<MatTab>;
Expand Down Expand Up @@ -321,6 +325,10 @@ export class MatTabGroup implements AfterViewInit, AfterContentInit, AfterConten
static ɵfac: i0.ɵɵFactoryDeclaration<MatTabGroup, never>;
}

// @public
export interface MatTabGroupBase {
}

// @public
export interface MatTabGroupBaseHeader {
// (undocumented)
Expand Down Expand Up @@ -368,7 +376,7 @@ export type MatTabHeaderPosition = 'above' | 'below';
// @public
export class MatTabLabel extends CdkPortal {
// (undocumented)
_closestTab: any;
_closestTab: MatTabBase | null;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatTabLabel, "[mat-tab-label], [matTabLabel]", never, {}, {}, never, never, true, never>;
// (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions goldens/material/timepicker/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ export class MatTimepickerInput<D> implements ControlValueAccessor, Validator, O
readonly min: InputSignalWithTransform<D | null, unknown>;
// (undocumented)
ngOnDestroy(): void;
registerOnChange(fn: (value: any) => void): void;
registerOnChange(fn: (value: unknown) => void): void;
registerOnTouched(fn: () => void): void;
registerOnValidatorChange(fn: () => void): void;
setDisabledState(isDisabled: boolean): void;
readonly timepicker: InputSignal<MatTimepicker<D>>;
validate(control: AbstractControl): ValidationErrors | null;
readonly value: ModelSignal<D | null>;
writeValue(value: any): void;
writeValue(value: unknown): void;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatTimepickerInput<any>, "input[matTimepicker]", ["matTimepickerInput"], { "value": { "alias": "value"; "required": false; "isSignal": true; }; "timepicker": { "alias": "matTimepicker"; "required": true; "isSignal": true; }; "min": { "alias": "matTimepickerMin"; "required": false; "isSignal": true; }; "max": { "alias": "matTimepickerMax"; "required": false; "isSignal": true; }; "disabledInput": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; }, never, never, true, never>;
// (undocumented)
Expand Down
6 changes: 3 additions & 3 deletions goldens/material/tooltip/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
y: number;
}): void;
get tooltipClass(): string | string[] | Set<string> | {
[key: string]: any;
[key: string]: unknown;
};
set tooltipClass(value: string | string[] | Set<string> | {
[key: string]: any;
[key: string]: unknown;
});
// (undocumented)
_tooltipInstance: TooltipComponent | null;
Expand Down Expand Up @@ -160,7 +160,7 @@ export class TooltipComponent implements OnDestroy {
show(delay: number): void;
_tooltip: ElementRef<HTMLElement>;
tooltipClass: string | string[] | Set<string> | {
[key: string]: any;
[key: string]: unknown;
};
_triggerElement: HTMLElement;
// (undocumented)
Expand Down
10 changes: 8 additions & 2 deletions src/material/snack-bar/simple-snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ import {MatSnackBarRef} from './snack-bar-ref';
import {MAT_SNACK_BAR_DATA} from './snack-bar-config';
import {MatSnackBarAction, MatSnackBarActions, MatSnackBarLabel} from './snack-bar-content';

/** Input data for the snack bar. */
export interface TextOnlySnackBarData {
message: string;
action: string;
}

/**
* Interface for a simple snack bar component that has a message and a single action.
*/
export interface TextOnlySnackBar {
data: {message: string; action: string};
data: TextOnlySnackBarData;
snackBarRef: MatSnackBarRef<TextOnlySnackBar>;
action: () => void;
hasAction: boolean;
Expand All @@ -36,7 +42,7 @@ export interface TextOnlySnackBar {
})
export class SimpleSnackBar implements TextOnlySnackBar {
snackBarRef = inject<MatSnackBarRef<SimpleSnackBar>>(MatSnackBarRef);
data = inject(MAT_SNACK_BAR_DATA);
data = inject<TextOnlySnackBarData>(MAT_SNACK_BAR_DATA);

constructor(...args: unknown[]);
constructor() {}
Expand Down
4 changes: 2 additions & 2 deletions src/material/snack-bar/snack-bar-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {AriaLivePoliteness} from '@angular/cdk/a11y';
import {Direction} from '@angular/cdk/bidi';

/** Injection token that can be used to access the data that was passed in to a snack bar. */
export const MAT_SNACK_BAR_DATA = new InjectionToken<any>('MatSnackBarData');
export const MAT_SNACK_BAR_DATA = new InjectionToken<unknown>('MatSnackBarData');

/** Possible values for horizontalPosition on MatSnackBarConfig. */
export type MatSnackBarHorizontalPosition = 'start' | 'center' | 'end' | 'left' | 'right';
Expand All @@ -22,7 +22,7 @@ export type MatSnackBarVerticalPosition = 'top' | 'bottom';
/**
* Configuration used when opening a snack-bar.
*/
export class MatSnackBarConfig<D = any> {
export class MatSnackBarConfig<D = unknown> {
/** The politeness level for the MatAriaLiveAnnouncer announcement. */
politeness?: AriaLivePoliteness = 'polite';

Expand Down
15 changes: 10 additions & 5 deletions src/material/snack-bar/snack-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,11 @@ describe('MatSnackBar', () => {
});

it('should be able to inject arbitrary user data', () => {
const data: BurritosNotificationData = {
burritoType: 'Chimichanga',
};
const snackBarRef = snackBar.openFromComponent(BurritosNotification, {
data: {
burritoType: 'Chimichanga',
},
data,
});

expect(snackBarRef.instance.data)
Expand Down Expand Up @@ -1013,17 +1014,21 @@ class ComponentWithChildViewContainer {
`,
})
class ComponentWithTemplateRef {
@ViewChild(TemplateRef) templateRef: TemplateRef<any>;
@ViewChild(TemplateRef) templateRef: TemplateRef<unknown>;
localValue: string;
}

interface BurritosNotificationData {
burritoType: string;
}

/** Simple component for testing ComponentPortal. */
@Component({
template: '<p>Burritos are on the way.</p>',
})
class BurritosNotification {
snackBarRef = inject<MatSnackBarRef<BurritosNotification>>(MatSnackBarRef);
data = inject(MAT_SNACK_BAR_DATA);
data = inject<BurritosNotificationData>(MAT_SNACK_BAR_DATA);
}

@Component({
Expand Down
Loading
Loading