CloudWatch: Fix strict Typescript errors (#41160)

* CloudWatch: Fix strict typscript errors

* Update public/app/plugins/datasource/cloudwatch/components/ConfigEditor.tsx

Co-authored-by: Sarah Zinger <sarahzinger@users.noreply.github.com>

* Chore: reduce strict error

* Update ci-check-strict.sh

Co-authored-by: Sarah Zinger <sarahzinger@users.noreply.github.com>
Co-authored-by: Hugo Häggmark <hugo.haggmark@gmail.com>
This commit is contained in:
Josh Hunt
2021-11-02 13:16:46 +00:00
committed by GitHub
parent 6987ad7b4d
commit cb948d10e0
9 changed files with 40 additions and 16 deletions

View File

@@ -2,7 +2,7 @@ import React, { ChangeEvent } from 'react';
import { LegacyForms } from '@grafana/ui';
const { Switch } = LegacyForms;
import { PanelData } from '@grafana/data';
import { CloudWatchAnnotationQuery } from '../types';
import { CloudWatchAnnotationQuery, CloudWatchQuery } from '../types';
import { CloudWatchDatasource } from '../datasource';
import { QueryField, PanelQueryEditor } from './';
@@ -20,7 +20,7 @@ export function AnnotationQueryEditor(props: React.PropsWithChildren<Props>) {
<>
<PanelQueryEditor
{...props}
onChange={(editorQuery: CloudWatchAnnotationQuery) => onChange({ ...query, ...editorQuery })}
onChange={(editorQuery: CloudWatchQuery) => onChange({ ...query, ...editorQuery })}
onRunQuery={() => {}}
history={[]}
></PanelQueryEditor>

View File

@@ -71,10 +71,16 @@ function useAuthenticationWarning(jsonData: CloudWatchJsonData) {
function useDatasource(datasourceName: string) {
const [datasource, setDatasource] = useState<CloudWatchDatasource>();
useEffect(() => {
getDatasourceSrv()
.loadDatasource(datasourceName)
.then((datasource: CloudWatchDatasource) => setDatasource(datasource));
.then((datasource) => {
// It's really difficult to type .loadDatasource() because it's inherently untyped as it involves two JSON.parse()'s
// So a "as" type assertion here is a necessary evil.
setDatasource(datasource as CloudWatchDatasource);
});
}, [datasourceName]);
return datasource;
}

View File

@@ -42,7 +42,9 @@ export const CloudWatchLogsQueryEditor = memo(function CloudWatchLogsQueryEditor
datasource={datasource}
query={query}
onBlur={() => {}}
onChange={(val: CloudWatchLogsQuery) => onChange({ ...val, queryMode: 'Logs' })}
onChange={(val: CloudWatchQuery) => {
onChange({ ...val, queryMode: 'Logs' });
}}
onRunQuery={onRunQuery}
history={[]}
data={data}