Chore: some type fixes (#59030)

some type fixes
This commit is contained in:
Ashley Harrison
2022-11-29 15:52:08 +00:00
committed by GitHub
parent f485f8a8f8
commit 191ca1df86
13 changed files with 81 additions and 119 deletions

View File

@@ -7567,24 +7567,13 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"] [0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/app/plugins/panel/nodeGraph/useCategorizeFrames.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/nodeGraph/usePanning.ts:5381": [ "public/app/plugins/panel/nodeGraph/usePanning.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"] [0, 0, 0, "Do not use any type assertions.", "3"]
], ],
"public/app/plugins/panel/nodeGraph/useZoom.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"public/app/plugins/panel/nodeGraph/utils.ts:5381": [ "public/app/plugins/panel/nodeGraph/utils.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/plugins/panel/piechart/PieChart.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
@@ -7597,25 +7586,16 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/app/plugins/panel/stat/StatMigrations.test.ts:5381": [ "public/app/plugins/panel/stat/StatMigrations.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/app/plugins/panel/stat/StatMigrations.ts:5381": [ "public/app/plugins/panel/stat/StatMigrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"] [0, 0, 0, "Do not use any type assertions.", "2"]
], ],
"public/app/plugins/panel/stat/common.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
],
"public/app/plugins/panel/state-timeline/TimelineChart.tsx:5381": [ "public/app/plugins/panel/state-timeline/TimelineChart.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "2"]
], ],
"public/app/plugins/panel/state-timeline/migrations.ts:5381": [ "public/app/plugins/panel/state-timeline/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -7638,23 +7618,10 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/app/plugins/panel/state-timeline/utils.test.ts:5381": [ "public/app/plugins/panel/state-timeline/utils.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
], ],
"public/app/plugins/panel/state-timeline/utils.ts:5381": [ "public/app/plugins/panel/state-timeline/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
], ],
"public/app/plugins/panel/table-old/column_options.ts:5381": [ "public/app/plugins/panel/table-old/column_options.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -8020,16 +7987,10 @@ exports[`better eslint`] = {
"public/test/core/redux/reduxTester.ts:5381": [ "public/test/core/redux/reduxTester.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"]
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Do not use any type assertions.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"]
], ],
"public/test/core/thunk/thunkTester.ts:5381": [ "public/test/core/thunk/thunkTester.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -8043,43 +8004,32 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "8"] [0, 0, 0, "Unexpected any. Specify a different type.", "8"]
], ],
"public/test/global-jquery-shim.ts:5381": [ "public/test/global-jquery-shim.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/test/helpers/convertToStoreState.ts:5381": [ "public/test/helpers/convertToStoreState.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/test/helpers/createFetchResponse.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
], ],
"public/test/helpers/getDashboardModel.ts:5381": [ "public/test/helpers/getDashboardModel.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/test/helpers/initTemplateSrv.ts:5381": [ "public/test/helpers/initTemplateSrv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
], ],
"public/test/jest-setup.ts:5381": [ "public/test/jest-setup.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"]
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
], ],
"public/test/jest-shim.ts:5381": [ "public/test/jest-shim.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"], [0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"], [0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"], [0, 0, 0, "Unexpected any. Specify a different type.", "5"]
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"]
], ],
"public/test/lib/common.ts:5381": [ "public/test/lib/common.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
], ],
"public/test/matchers/index.ts:5381": [ "public/test/matchers/index.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@@ -8103,10 +8053,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "4"] [0, 0, 0, "Unexpected any. Specify a different type.", "4"]
], ],
"public/test/matchers/utils.ts:5381": [ "public/test/matchers/utils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
], ],
"public/test/mocks/angular.ts:5381": [ "public/test/mocks/angular.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -8123,16 +8070,11 @@ exports[`better eslint`] = {
], ],
"public/test/mocks/datasource_srv.ts:5381": [ "public/test/mocks/datasource_srv.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"]
], ],
"public/test/mocks/workers.ts:5381": [ "public/test/mocks/workers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"], [0, 0, 0, "Unexpected any. Specify a different type.", "1"]
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
], ],
"public/test/specs/helpers.ts:5381": [ "public/test/specs/helpers.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"], [0, 0, 0, "Unexpected any. Specify a different type.", "0"],
@@ -8144,14 +8086,13 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "6"], [0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"], [0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"], [0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Do not use any type assertions.", "9"], [0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"], [0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"], [0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"], [0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"], [0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"], [0, 0, 0, "Unexpected any. Specify a different type.", "15"]
[0, 0, 0, "Unexpected any. Specify a different type.", "16"]
] ]
}` }`
}; };

View File

@@ -36,7 +36,10 @@ function countEslintErrors() {
}; };
const isTestFile = const isTestFile =
filePath.endsWith('.test.tsx') || filePath.endsWith('.test.ts') || filePath.includes('__mocks__'); filePath.endsWith('.test.tsx') ||
filePath.endsWith('.test.ts') ||
filePath.includes('__mocks__') ||
filePath.includes('public/test/');
if (!isTestFile) { if (!isTestFile) {
rules['@typescript-eslint/consistent-type-assertions'] = [ rules['@typescript-eslint/consistent-type-assertions'] = [

View File

@@ -9,7 +9,10 @@ import { DataFrame } from '@grafana/data';
*/ */
export function useCategorizeFrames(series: DataFrame[]) { export function useCategorizeFrames(series: DataFrame[]) {
return useMemo(() => { return useMemo(() => {
return series.reduce( return series.reduce<{
nodes: DataFrame[];
edges: DataFrame[];
}>(
(acc, frame) => { (acc, frame) => {
const sourceField = frame.fields.filter((f) => f.name === 'source'); const sourceField = frame.fields.filter((f) => f.name === 'source');
if (sourceField.length) { if (sourceField.length) {
@@ -19,7 +22,7 @@ export function useCategorizeFrames(series: DataFrame[]) {
} }
return acc; return acc;
}, },
{ edges: [], nodes: [] } as { nodes: DataFrame[]; edges: DataFrame[] } { edges: [], nodes: [] }
); );
}, [series]); }, [series]);
} }

View File

@@ -44,14 +44,13 @@ export function useZoom({ stepUp, stepDown, min, max } = defaultOptions) {
}, [scale, stepDown, min]); }, [scale, stepDown, min]);
const onWheel = useCallback( const onWheel = useCallback(
function (event: Event) { function (wheelEvent: WheelEvent) {
// Seems like typing for the addEventListener is lacking a bit // Seems like typing for the addEventListener is lacking a bit
const wheelEvent = event as WheelEvent;
// Only do this with special key pressed similar to how google maps work. // Only do this with special key pressed similar to how google maps work.
// TODO: I would guess this won't work very well with touch right now // TODO: I would guess this won't work very well with touch right now
if (wheelEvent.ctrlKey || wheelEvent.metaKey) { if (wheelEvent.ctrlKey || wheelEvent.metaKey) {
event.preventDefault(); wheelEvent.preventDefault();
setScale(Math.min(Math.max(min ?? -Infinity, scale + Math.min(wheelEvent.deltaY, 2) * -0.01), max ?? Infinity)); setScale(Math.min(Math.max(min ?? -Infinity, scale + Math.min(wheelEvent.deltaY, 2) * -0.01), max ?? Infinity));

View File

@@ -213,7 +213,7 @@ function processEdges(edges: DataFrame, edgeFields: EdgeFields): EdgeDatum[] {
secondaryStat: edgeFields.secondaryStat secondaryStat: edgeFields.secondaryStat
? statToString(edgeFields.secondaryStat.config, edgeFields.secondaryStat.values.get(index)) ? statToString(edgeFields.secondaryStat.config, edgeFields.secondaryStat.values.get(index))
: '', : '',
} as EdgeDatum; };
}); });
} }

View File

@@ -199,7 +199,7 @@ function PieSlice({ arc, pie, highlightState, openMenu, fill, tooltip, tooltipOp
const { eventBus } = usePanelContext(); const { eventBus } = usePanelContext();
const onMouseOut = useCallback( const onMouseOut = useCallback(
(event: any) => { (event: React.MouseEvent<SVGGElement>) => {
eventBus?.publish({ eventBus?.publish({
type: DataHoverClearEvent.type, type: DataHoverClearEvent.type,
payload: { payload: {
@@ -215,7 +215,7 @@ function PieSlice({ arc, pie, highlightState, openMenu, fill, tooltip, tooltipOp
); );
const onMouseMoveOverArc = useCallback( const onMouseMoveOverArc = useCallback(
(event: any) => { (event: React.MouseEvent<SVGGElement>) => {
eventBus?.publish({ eventBus?.publish({
type: DataHoverEvent.type, type: DataHoverEvent.type,
payload: { payload: {
@@ -226,12 +226,16 @@ function PieSlice({ arc, pie, highlightState, openMenu, fill, tooltip, tooltipOp
}, },
}); });
const coords = localPoint(event.target.ownerSVGElement, event); const owner = event.currentTarget.ownerSVGElement;
tooltip.showTooltip({
tooltipLeft: coords!.x, if (owner) {
tooltipTop: coords!.y, const coords = localPoint(owner, event);
tooltipData: getTooltipData(pie, arc, tooltipOptions), tooltip.showTooltip({
}); tooltipLeft: coords!.x,
tooltipTop: coords!.y,
tooltipData: getTooltipData(pie, arc, tooltipOptions),
});
}
}, },
[eventBus, arc, tooltip, pie, tooltipOptions] [eventBus, arc, tooltip, pie, tooltipOptions]
); );

View File

@@ -5,7 +5,7 @@ import { statPanelChangedHandler } from './StatMigrations';
describe('Stat Panel Migrations', () => { describe('Stat Panel Migrations', () => {
it('change from angular singlestat sparkline disabled', () => { it('change from angular singlestat sparkline disabled', () => {
const old: any = { const old = {
angular: { angular: {
format: 'ms', format: 'ms',
decimals: 7, decimals: 7,
@@ -21,7 +21,7 @@ describe('Stat Panel Migrations', () => {
}); });
it('change from angular singlestat sparkline enabled', () => { it('change from angular singlestat sparkline enabled', () => {
const old: any = { const old = {
angular: { angular: {
format: 'ms', format: 'ms',
decimals: 7, decimals: 7,
@@ -37,7 +37,7 @@ describe('Stat Panel Migrations', () => {
}); });
it('change from angular singlestat color background', () => { it('change from angular singlestat color background', () => {
const old: any = { const old = {
angular: { angular: {
format: 'ms', format: 'ms',
decimals: 7, decimals: 7,
@@ -51,7 +51,7 @@ describe('Stat Panel Migrations', () => {
}); });
it('change from angular singlestat with name stat', () => { it('change from angular singlestat with name stat', () => {
const old: any = { const old = {
angular: { angular: {
valueName: 'name', valueName: 'name',
}, },

View File

@@ -50,7 +50,7 @@ export function addStandardDataReduceOptions<T extends SingleStatBaseOptions>(
name: 'Calculation', name: 'Calculation',
description: 'Choose a reducer function / calculation', description: 'Choose a reducer function / calculation',
category: valueOptionsCategory, category: valueOptionsCategory,
editor: standardEditorsRegistry.get('stats-picker').editor as any, editor: standardEditorsRegistry.get('stats-picker').editor,
// TODO: Get ReducerID from generated schema one day? // TODO: Get ReducerID from generated schema one day?
defaultValue: [ReducerID.lastNotNull], defaultValue: [ReducerID.lastNotNull],
// Hides it when all values mode is on // Hides it when all values mode is on

View File

@@ -50,7 +50,7 @@ export class TimelineChart extends React.Component<TimelineProps> {
}; };
prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => { prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => {
this.panelContext = this.context as PanelContext; this.panelContext = this.context;
const { eventBus, sync } = this.panelContext; const { eventBus, sync } = this.panelContext;
return preparePlotConfigBuilder({ return preparePlotConfigBuilder({

View File

@@ -1,5 +1,5 @@
import { ArrayVector, createTheme, FieldType, ThresholdsMode, TimeRange, toDataFrame, dateTime } from '@grafana/data'; import { ArrayVector, createTheme, FieldType, ThresholdsMode, TimeRange, toDataFrame, dateTime } from '@grafana/data';
import { LegendDisplayMode } from '@grafana/schema'; import { LegendDisplayMode, VizLegendOptions } from '@grafana/schema';
import { import {
findNextStateIndex, findNextStateIndex,
@@ -15,7 +15,10 @@ describe('prepare timeline graph', () => {
const timeRange: TimeRange = { const timeRange: TimeRange = {
from: dateTime(1), from: dateTime(1),
to: dateTime(3), to: dateTime(3),
raw: {} as any, raw: {
from: dateTime(1),
to: dateTime(3),
},
}; };
it('errors with no time fields', () => { it('errors with no time fields', () => {
const frames = [ const frames = [
@@ -92,7 +95,8 @@ describe('findNextStateIndex', () => {
name: 'time', name: 'time',
type: FieldType.number, type: FieldType.number,
values: new ArrayVector([1, undefined, undefined, 2, undefined, undefined]), values: new ArrayVector([1, undefined, undefined, 2, undefined, undefined]),
} as any; config: {},
};
const result = findNextStateIndex(field, 0); const result = findNextStateIndex(field, 0);
expect(result).toEqual(3); expect(result).toEqual(3);
}); });
@@ -102,7 +106,8 @@ describe('findNextStateIndex', () => {
name: 'time', name: 'time',
type: FieldType.number, type: FieldType.number,
values: new ArrayVector([1, undefined, undefined, 2, undefined, 3]), values: new ArrayVector([1, undefined, undefined, 2, undefined, 3]),
} as any; config: {},
};
const result = findNextStateIndex(field, 5); const result = findNextStateIndex(field, 5);
expect(result).toEqual(null); expect(result).toEqual(null);
}); });
@@ -112,7 +117,8 @@ describe('findNextStateIndex', () => {
name: 'time', name: 'time',
type: FieldType.number, type: FieldType.number,
values: new ArrayVector([1, undefined, undefined, 2, undefined, 3, undefined]), values: new ArrayVector([1, undefined, undefined, 2, undefined, 3, undefined]),
} as any; config: {},
};
const result = findNextStateIndex(field, 5); const result = findNextStateIndex(field, 5);
expect(result).toEqual(null); expect(result).toEqual(null);
}); });
@@ -134,7 +140,8 @@ describe('findNextStateIndex', () => {
undefined, undefined,
undefined, undefined,
]), ]),
} as any; config: {},
};
const result = findNextStateIndex(field, 3); const result = findNextStateIndex(field, 3);
expect(result).toEqual(8); expect(result).toEqual(8);
}); });
@@ -144,7 +151,8 @@ describe('findNextStateIndex', () => {
name: 'time', name: 'time',
type: FieldType.number, type: FieldType.number,
values: new ArrayVector([1, 3, 2]), values: new ArrayVector([1, 3, 2]),
} as any; config: {},
};
test('leading', () => { test('leading', () => {
const result = findNextStateIndex(field, 0); const result = findNextStateIndex(field, 0);
@@ -232,7 +240,11 @@ describe('prepareTimelineLegendItems', () => {
}, },
]; ];
const result = prepareTimelineLegendItems(frame, { displayMode: LegendDisplayMode.List } as any, theme); const result = prepareTimelineLegendItems(
frame,
{ displayMode: LegendDisplayMode.List } as VizLegendOptions,
theme
);
expect(result).toHaveLength(1); expect(result).toHaveLength(1);
}); });

View File

@@ -209,7 +209,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<TimelineOptions> = ({
} }
const field = frame.fields[i]; const field = frame.fields[i];
const config = field.config as FieldConfig<TimelineFieldConfig>; const config: FieldConfig<TimelineFieldConfig> = field.config;
const customConfig: TimelineFieldConfig = { const customConfig: TimelineFieldConfig = {
...defaultConfig, ...defaultConfig,
...config.custom, ...config.custom,
@@ -259,8 +259,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<TimelineOptions> = ({
return true; return true;
}, },
}, },
//TODO: remove any once https://github.com/leeoniya/uPlot/pull/611 got merged or the typing is fixed scales: [xScaleKey, null],
scales: [xScaleKey, null as any],
}; };
builder.setSync(); builder.setSync();
builder.setCursor(cursor); builder.setCursor(cursor);
@@ -284,9 +283,9 @@ export function getNamesToFieldIndex(frame: DataFrame): Map<string, number> {
* in: 1, 1,undefined, 1,2, 2,null,2,3 * in: 1, 1,undefined, 1,2, 2,null,2,3
* out: 1,undefined,undefined,undefined,2,undefined,null,2,3 * out: 1,undefined,undefined,undefined,2,undefined,null,2,3
*/ */
export function unsetSameFutureValues(values: any[]): any[] | undefined { export function unsetSameFutureValues(values: unknown[]): unknown[] | undefined {
let prevVal = values[0]; let prevVal = values[0];
let clone: any[] | undefined = undefined; let clone: unknown[] | undefined = undefined;
for (let i = 1; i < values.length; i++) { for (let i = 1; i < values.length; i++) {
let value = values[i]; let value = values[i];

View File

@@ -1,6 +1,7 @@
import { DashboardModel } from '../../app/features/dashboard/state'; import { DashboardModel } from '../../app/features/dashboard/state';
import { DashboardMeta } from '../../app/types/dashboard';
export const getDashboardModel = (json: any, meta: any = {}) => { export const getDashboardModel = (json: any, meta: DashboardMeta = {}) => {
const getVariablesFromState = () => json.templating.list; const getVariablesFromState = () => json.templating.list;
return new DashboardModel(json, meta, getVariablesFromState); return new DashboardModel(json, meta, getVariablesFromState);
}; };

View File

@@ -22,7 +22,7 @@ export function forceObservableCompletion(subscription: Subscription, resolve: (
); );
} }
export function expectObservableToBeDefined(received: any): jest.CustomMatcherResult | null { export function expectObservableToBeDefined(received: unknown): jest.CustomMatcherResult | null {
if (received) { if (received) {
return null; return null;
} }
@@ -35,7 +35,7 @@ Expected ${printReceived(received)} to be ${printExpected('defined')}.`,
}; };
} }
export function expectObservableToBeObservable(received: any): jest.CustomMatcherResult | null { export function expectObservableToBeObservable(received: unknown): jest.CustomMatcherResult | null {
if (isObservable(received)) { if (isObservable(received)) {
return null; return null;
} }
@@ -48,7 +48,7 @@ Expected ${printReceived(received)} to be ${printExpected('an Observable')}.`,
}; };
} }
export function expectObservable(received: any): jest.CustomMatcherResult | null { export function expectObservable(received: unknown): jest.CustomMatcherResult | null {
const toBeDefined = expectObservableToBeDefined(received); const toBeDefined = expectObservableToBeDefined(received);
if (toBeDefined) { if (toBeDefined) {
return toBeDefined; return toBeDefined;