diff --git a/public/app/features/dashboard/state/PanelModel.ts b/public/app/features/dashboard/state/PanelModel.ts index 59faf2587e2..4a7f8b8be05 100644 --- a/public/app/features/dashboard/state/PanelModel.ts +++ b/public/app/features/dashboard/state/PanelModel.ts @@ -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; diff --git a/public/app/features/panel/query_ctrl.ts b/public/app/features/panel/query_ctrl.ts index aa3b3016135..c0a2d46b531 100644 --- a/public/app/features/panel/query_ctrl.ts +++ b/public/app/features/panel/query_ctrl.ts @@ -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; diff --git a/public/app/features/profile/ChangePasswordPage.tsx b/public/app/features/profile/ChangePasswordPage.tsx index c3c2553dabc..5c3346123fb 100644 --- a/public/app/features/profile/ChangePasswordPage.tsx +++ b/public/app/features/profile/ChangePasswordPage.tsx @@ -23,7 +23,7 @@ export const ChangePasswordPage: FC = ({ navModel }) => ( teams: Team[], orgs: UserOrg[], sessions: UserSession[], - user: UserDTO + user?: UserDTO ) => { return ( @@ -31,7 +31,7 @@ export const ChangePasswordPage: FC = ({ navModel }) => ( {states.loadUser ? ( ) : ( - + )} ); diff --git a/public/app/features/profile/UserProfileEdit.tsx b/public/app/features/profile/UserProfileEdit.tsx index 79a29d58980..135065856cd 100644 --- a/public/app/features/profile/UserProfileEdit.tsx +++ b/public/app/features/profile/UserProfileEdit.tsx @@ -27,7 +27,7 @@ export const UserProfileEdit: FC = ({ navModel }) => ( teams: Team[], orgs: UserOrg[], sessions: UserSession[], - user: UserDTO + user?: UserDTO ) => { return ( @@ -37,7 +37,7 @@ export const UserProfileEdit: FC = ({ navModel }) => ( )} @@ -49,14 +49,14 @@ export const UserProfileEdit: FC = ({ navModel }) => ( setUserOrg={api.setUserOrg} loadOrgs={api.loadOrgs} orgs={orgs} - user={user} + user={user!} /> )} diff --git a/public/app/features/query/state/runRequest.test.ts b/public/app/features/query/state/runRequest.test.ts index eec5ac41e5b..981ee3e5113 100644 --- a/public/app/features/query/state/runRequest.test.ts +++ b/public/app/features/query/state/runRequest.test.ts @@ -30,13 +30,13 @@ jest.mock('app/features/dashboard/services/DashboardSrv', () => ({ })); class ScenarioCtx { - ds: DataSourceApi; - request: DataQueryRequest; - subscriber: Subscriber; + ds!: DataSourceApi; + request!: DataQueryRequest; + subscriber!: Subscriber; isUnsubbed = false; setupFn: () => void = () => {}; - results: PanelData[]; - subscription: Subscription; + results!: PanelData[]; + subscription!: Subscription; wasStarted = false; error: Error | null = null; toStartTime = dateTime(); diff --git a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/aggregations.ts b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/aggregations.ts index 7e31380fce6..b56fedd6480 100644 --- a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/aggregations.ts +++ b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/aggregations.ts @@ -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; diff --git a/public/app/plugins/datasource/mysql/query_ctrl.ts b/public/app/plugins/datasource/mysql/query_ctrl.ts index 00421e13913..f146a7af9e6 100644 --- a/public/app/plugins/datasource/mysql/query_ctrl.ts +++ b/public/app/plugins/datasource/mysql/query_ctrl.ts @@ -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', diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index 3812b61bada..73f177b8bce 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -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); ///////////////////////////// diff --git a/public/app/plugins/panel/stat/types.ts b/public/app/plugins/panel/stat/types.ts index 197c0d86e86..40207a654d9 100644 --- a/public/app/plugins/panel/stat/types.ts +++ b/public/app/plugins/panel/stat/types.ts @@ -23,8 +23,8 @@ export interface StatPanelOptions extends SingleStatBaseOptions { textMode: BigValueTextMode; } -export function addStandardDataReduceOptions( - builder: PanelOptionsEditorBuilder, +export function addStandardDataReduceOptions( + builder: PanelOptionsEditorBuilder, includeOrientation = true, includeFieldMatcher = true, includeTextSizes = true diff --git a/public/app/plugins/panel/timeseries/config.ts b/public/app/plugins/panel/timeseries/config.ts index 84d0d8cfb95..7bc9e3abd3a 100644 --- a/public/app/plugins/panel/timeseries/config.ts +++ b/public/app/plugins/panel/timeseries/config.ts @@ -261,7 +261,7 @@ export function addAxisConfig( } } -export function addLegendOptions(builder: PanelOptionsEditorBuilder) { +export function addLegendOptions(builder: PanelOptionsEditorBuilder) { builder .addRadio({ path: 'legend.displayMode', diff --git a/scripts/ci-check-strict.sh b/scripts/ci-check-strict.sh index fed81064d43..bef8fc7bd9a 100755 --- a/scripts/ci-check-strict.sh +++ b/scripts/ci-check-strict.sh @@ -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