Chore: Improve some types (#64675)

* some type fixes

* few more

* more type fixes

* fix the majority of (window as any) calls

* don't make new variable for event

* few more

* MOAR
This commit is contained in:
Ashley Harrison
2023-03-14 09:51:44 +00:00
committed by GitHub
parent aade4b0bd2
commit 53186c14a4
73 changed files with 256 additions and 436 deletions

View File

@@ -13,7 +13,7 @@ export interface OptionsPaneItemProps {
value?: any;
description?: string;
popularRank?: number;
render: () => React.ReactNode;
render: () => React.ReactElement;
skipField?: boolean;
showIf?: () => boolean;
overrides?: OptionPaneItemOverrideInfo[];
@@ -94,7 +94,7 @@ export class OptionsPaneItemDescriptor {
key={key}
aria-label={selectors.components.PanelEditor.OptionsPane.fieldLabel(key)}
>
{render() as React.ReactElement}
{render()}
</Field>
);
}

View File

@@ -167,13 +167,13 @@ export class PanelEditorUnconnected extends PureComponent<Props> {
});
};
onPanelOptionsChanged = (options: any) => {
onPanelOptionsChanged = (options: PanelModel['options']) => {
// we do not need to trigger force update here as the function call below
// fires PanelOptionsChangedEvent which we subscribe to above
this.props.panel.updateOptions(options);
};
onPanelConfigChanged = (configKey: keyof PanelModel, value: any) => {
onPanelConfigChanged = (configKey: keyof PanelModel, value: unknown) => {
this.props.panel.setProperty(configKey, value);
this.props.panel.render();
this.forceUpdate();

View File

@@ -155,7 +155,7 @@ export function getFieldOverrideCategories(
continue;
}
const onPropertyChange = (value: any) => {
const onPropertyChange = (value: DynamicConfigValue) => {
override.properties[propIdx].value = value;
onOverrideChange(idx, override);
};

View File

@@ -82,8 +82,8 @@ export function getVisualizationOptions(props: OptionPaneRenderProps): OptionsPa
};
const access: NestedValueAccess = {
getValue: (path: string) => lodashGet(currentOptions, path),
onChange: (path: string, value: any) => {
getValue: (path) => lodashGet(currentOptions, path),
onChange: (path, value) => {
const newOptions = setOptionImmutably(currentOptions, path, value);
onPanelOptionsChanged(newOptions);
},

View File

@@ -56,8 +56,8 @@ export interface OptionPaneRenderProps {
data?: PanelData;
dashboard: DashboardModel;
instanceState: any;
onPanelConfigChange: (configKey: keyof PanelModel, value: any) => void;
onPanelOptionsChanged: (options: any) => void;
onPanelConfigChange: (configKey: keyof PanelModel, value: unknown) => void;
onPanelOptionsChanged: (options: PanelModel['options']) => void;
onFieldConfigsChange: (config: FieldConfigSource) => void;
}