Commit 372ae7fd by Torkel Ödegaard Committed by GitHub

Chore: Fix strict errors, down to 416 (#31365)

parent ad5514ec
......@@ -107,15 +107,16 @@ const defaults: any = {
transparent: false,
options: {},
datasource: null,
title: '',
};
export class PanelModel implements DataConfigSource {
/* persisted id, used in URL to identify a panel */
id: number;
editSourceId: number;
gridPos: GridPos;
type: string;
title: string;
id!: number;
editSourceId?: number;
gridPos!: GridPos;
type!: string;
title!: string;
alert?: any;
scopedVars?: ScopedVars;
repeat?: string;
......
......@@ -2,11 +2,11 @@ import _ from 'lodash';
import { auto } from 'angular';
export class QueryCtrl {
target: any;
datasource: any;
panelCtrl: any;
target!: any;
datasource!: any;
panelCtrl!: any;
panel: any;
hasRawMode: boolean;
hasRawMode!: boolean;
error?: string | null;
isLastQuery: boolean;
......
......@@ -23,7 +23,7 @@ export const ChangePasswordPage: FC<Props> = ({ navModel }) => (
teams: Team[],
orgs: UserOrg[],
sessions: UserSession[],
user: UserDTO
user?: UserDTO
) => {
return (
<Page.Contents>
......@@ -31,7 +31,7 @@ export const ChangePasswordPage: FC<Props> = ({ navModel }) => (
{states.loadUser ? (
<LoadingPlaceholder text="Loading user profile..." />
) : (
<ChangePasswordForm user={user} onChangePassword={api.changePassword} isSaving={states.changePassword} />
<ChangePasswordForm user={user!} onChangePassword={api.changePassword} isSaving={states.changePassword} />
)}
</Page.Contents>
);
......
......@@ -27,7 +27,7 @@ export const UserProfileEdit: FC<Props> = ({ navModel }) => (
teams: Team[],
orgs: UserOrg[],
sessions: UserSession[],
user: UserDTO
user?: UserDTO
) => {
return (
<Page.Contents>
......@@ -37,7 +37,7 @@ export const UserProfileEdit: FC<Props> = ({ navModel }) => (
<UserProfileEditForm
updateProfile={api.updateUserProfile}
isSavingUser={states.updateUserProfile}
user={user}
user={user!}
/>
)}
<SharedPreferences resourceUri="user" />
......@@ -49,14 +49,14 @@ export const UserProfileEdit: FC<Props> = ({ navModel }) => (
setUserOrg={api.setUserOrg}
loadOrgs={api.loadOrgs}
orgs={orgs}
user={user}
user={user!}
/>
<UserSessions
isLoading={states.loadSessions}
loadSessions={api.loadSessions}
revokeUserSession={api.revokeUserSession}
sessions={sessions}
user={user}
user={user!}
/>
</>
)}
......
......@@ -30,13 +30,13 @@ jest.mock('app/features/dashboard/services/DashboardSrv', () => ({
}));
class ScenarioCtx {
ds: DataSourceApi;
request: DataQueryRequest;
subscriber: Subscriber<DataQueryResponse>;
ds!: DataSourceApi;
request!: DataQueryRequest;
subscriber!: Subscriber<DataQueryResponse>;
isUnsubbed = false;
setupFn: () => void = () => {};
results: PanelData[];
subscription: Subscription;
results!: PanelData[];
subscription!: Subscription;
wasStarted = false;
error: Error | null = null;
toStartTime = dateTime();
......
......@@ -49,11 +49,11 @@ export interface MetricAggregationWithInlineScript extends BaseMetricAggregation
};
}
interface Count extends BaseMetricAggregation {
export interface Count extends BaseMetricAggregation {
type: 'count';
}
interface Average
export interface Average
extends MetricAggregationWithField,
MetricAggregationWithMissingSupport,
MetricAggregationWithInlineScript {
......@@ -64,7 +64,7 @@ interface Average
};
}
interface Sum extends MetricAggregationWithField, MetricAggregationWithInlineScript {
export interface Sum extends MetricAggregationWithField, MetricAggregationWithInlineScript {
type: 'sum';
settings?: {
script?: string;
......@@ -72,7 +72,7 @@ interface Sum extends MetricAggregationWithField, MetricAggregationWithInlineScr
};
}
interface Max extends MetricAggregationWithField, MetricAggregationWithInlineScript {
export interface Max extends MetricAggregationWithField, MetricAggregationWithInlineScript {
type: 'max';
settings?: {
script?: string;
......@@ -80,7 +80,7 @@ interface Max extends MetricAggregationWithField, MetricAggregationWithInlineScr
};
}
interface Min extends MetricAggregationWithField, MetricAggregationWithInlineScript {
export interface Min extends MetricAggregationWithField, MetricAggregationWithInlineScript {
type: 'min';
settings?: {
script?: string;
......@@ -131,21 +131,21 @@ export interface UniqueCount extends MetricAggregationWithField {
};
}
interface RawDocument extends BaseMetricAggregation {
export interface RawDocument extends BaseMetricAggregation {
type: 'raw_document';
settings?: {
size?: string;
};
}
interface RawData extends BaseMetricAggregation {
export interface RawData extends BaseMetricAggregation {
type: 'raw_data';
settings?: {
size?: string;
};
}
interface Logs extends BaseMetricAggregation {
export interface Logs extends BaseMetricAggregation {
type: 'logs';
}
......@@ -154,7 +154,7 @@ export interface BasePipelineMetricAggregation extends MetricAggregationWithFiel
pipelineAgg?: string;
}
interface PipelineMetricAggregationWithMultipleBucketPaths extends BaseMetricAggregation {
export interface PipelineMetricAggregationWithMultipleBucketPaths extends BaseMetricAggregation {
type: PipelineMetricAggregationType;
pipelineVariables?: PipelineVariable[];
}
......@@ -166,26 +166,27 @@ export interface MovingAverageModelOption {
value: MovingAverageModel;
}
interface BaseMovingAverageModelSettings {
export interface BaseMovingAverageModelSettings {
model: MovingAverageModel;
window: number;
predict: number;
}
interface MovingAverageSimpleModelSettings extends BaseMovingAverageModelSettings {
export interface MovingAverageSimpleModelSettings extends BaseMovingAverageModelSettings {
model: 'simple';
}
interface MovingAverageLinearModelSettings extends BaseMovingAverageModelSettings {
export interface MovingAverageLinearModelSettings extends BaseMovingAverageModelSettings {
model: 'linear';
}
interface MovingAverageEWMAModelSettings extends BaseMovingAverageModelSettings {
export interface MovingAverageEWMAModelSettings extends BaseMovingAverageModelSettings {
model: 'ewma';
alpha: number;
minimize: boolean;
}
interface MovingAverageHoltModelSettings extends BaseMovingAverageModelSettings {
export interface MovingAverageHoltModelSettings extends BaseMovingAverageModelSettings {
model: 'holt';
settings: {
alpha?: number;
......@@ -193,7 +194,8 @@ interface MovingAverageHoltModelSettings extends BaseMovingAverageModelSettings
};
minimize: boolean;
}
interface MovingAverageHoltWintersModelSettings extends BaseMovingAverageModelSettings {
export interface MovingAverageHoltWintersModelSettings extends BaseMovingAverageModelSettings {
model: 'holt_winters';
settings: {
alpha?: number;
......@@ -232,7 +234,7 @@ export const isHoltWintersMovingAverage = (
metric: MovingAverage | MovingAverage<'holt_winters'>
): metric is MovingAverage<'holt_winters'> => metric.settings?.model === 'holt_winters';
interface MovingFunction extends BasePipelineMetricAggregation {
export interface MovingFunction extends BasePipelineMetricAggregation {
type: 'moving_fn';
settings?: {
window?: string;
......@@ -255,7 +257,7 @@ export interface SerialDiff extends BasePipelineMetricAggregation {
};
}
interface CumulativeSum extends BasePipelineMetricAggregation {
export interface CumulativeSum extends BasePipelineMetricAggregation {
type: 'cumulative_sum';
settings?: {
format?: string;
......
......@@ -25,7 +25,7 @@ export class MysqlQueryCtrl extends QueryCtrl {
formats: any[];
lastQueryError?: string;
showHelp: boolean;
showHelp!: boolean;
queryModel: MysqlQuery;
metaBuilder: MysqlMetaQuery;
......@@ -34,10 +34,10 @@ export class MysqlQueryCtrl extends QueryCtrl {
whereAdd: any;
timeColumnSegment: any;
metricColumnSegment: any;
selectMenu: any[];
selectParts: SqlPart[][];
groupParts: SqlPart[];
whereParts: SqlPart[];
selectMenu: any[] = [];
selectParts: SqlPart[][] = [];
groupParts: SqlPart[] = [];
whereParts: SqlPart[] = [];
groupAdd: any;
/** @ngInject */
......@@ -136,7 +136,6 @@ export class MysqlQueryCtrl extends QueryCtrl {
}
buildSelectMenu() {
this.selectMenu = [];
const aggregates = {
text: 'Aggregate Functions',
value: 'aggregate',
......
......@@ -33,20 +33,20 @@ export default function rendering(scope: any, elem: any, attrs: any, ctrl: any)
return new HeatmapRenderer(scope, elem, attrs, ctrl);
}
export class HeatmapRenderer {
width: number;
height: number;
width = 200;
height = 200;
yScale: any;
xScale: any;
chartWidth: number;
chartHeight: number;
chartTop: number;
chartBottom: number;
yAxisWidth: number;
xAxisHeight: number;
cardPadding: number;
cardRound: number;
cardWidth: number;
cardHeight: number;
chartWidth = 0;
chartHeight = 0;
chartTop = 0;
chartBottom = 0;
yAxisWidth = 0;
xAxisHeight = 0;
cardPadding = 0;
cardRound = 0;
cardWidth = 0;
cardHeight = 0;
colorScale: any;
opacityScale: any;
mouseUpHandler: any;
......@@ -61,6 +61,7 @@ export class HeatmapRenderer {
padding: any;
margin: any;
dataRangeWidingFactor: number;
constructor(private scope: any, private elem: any, attrs: any, private ctrl: any) {
// $heatmap is JQuery object, but heatmap is D3
this.$heatmap = this.elem.find('.heatmap-panel');
......@@ -75,9 +76,7 @@ export class HeatmapRenderer {
this.padding = { left: 0, right: 0, top: 0, bottom: 0 };
this.margin = { left: 25, right: 15, top: 10, bottom: 20 };
this.dataRangeWidingFactor = DATA_RANGE_WIDING_FACTOR;
this.ctrl.events.on(PanelEvents.render, this.onRender.bind(this));
this.ctrl.tickValueFormatter = this.tickValueFormatter.bind(this);
/////////////////////////////
......
......@@ -23,8 +23,8 @@ export interface StatPanelOptions extends SingleStatBaseOptions {
textMode: BigValueTextMode;
}
export function addStandardDataReduceOptions(
builder: PanelOptionsEditorBuilder<SingleStatBaseOptions>,
export function addStandardDataReduceOptions<T extends SingleStatBaseOptions>(
builder: PanelOptionsEditorBuilder<T>,
includeOrientation = true,
includeFieldMatcher = true,
includeTextSizes = true
......
......@@ -261,7 +261,7 @@ export function addAxisConfig(
}
}
export function addLegendOptions(builder: PanelOptionsEditorBuilder<OptionsWithLegend>) {
export function addLegendOptions<T extends OptionsWithLegend>(builder: PanelOptionsEditorBuilder<T>) {
builder
.addRadio({
path: 'legend.displayMode',
......
......@@ -3,7 +3,7 @@ set -e
echo -e "Collecting code stats (typescript errors & more)"
ERROR_COUNT_LIMIT=452
ERROR_COUNT_LIMIT=416
ERROR_COUNT="$(./node_modules/.bin/tsc --project tsconfig.json --noEmit --strict true | grep -oP 'Found \K(\d+)')"
if [ "$ERROR_COUNT" -gt $ERROR_COUNT_LIMIT ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment