Browse Source

Merge pull request #15946 from grafana/typescript-any-fixes-part1

Progress on fixing typescript noImplicitAny issues
Torkel Ödegaard 7 years ago
parent
commit
5cabf64fa4

+ 1 - 0
package.json

@@ -17,6 +17,7 @@
     "@babel/preset-react": "^7.0.0",
     "@babel/preset-react": "^7.0.0",
     "@babel/preset-typescript": "^7.1.0",
     "@babel/preset-typescript": "^7.1.0",
     "@rtsao/plugin-proposal-class-properties": "^7.0.1-patch.1",
     "@rtsao/plugin-proposal-class-properties": "^7.0.1-patch.1",
+    "@types/angular": "^1.6.6",
     "@types/chalk": "^2.2.0",
     "@types/chalk": "^2.2.0",
     "@types/classnames": "^2.2.6",
     "@types/classnames": "^2.2.6",
     "@types/commander": "^2.12.2",
     "@types/commander": "^2.12.2",

+ 2 - 3
packages/grafana-ui/src/components/Gauge/Gauge.tsx

@@ -30,7 +30,7 @@ const FONT_SCALE = 1;
 export class Gauge extends PureComponent<Props> {
 export class Gauge extends PureComponent<Props> {
   canvasElement: any;
   canvasElement: any;
 
 
-  static defaultProps = {
+  static defaultProps: Partial<Props> = {
     maxValue: 100,
     maxValue: 100,
     valueMappings: [],
     valueMappings: [],
     minValue: 0,
     minValue: 0,
@@ -41,7 +41,6 @@ export class Gauge extends PureComponent<Props> {
     thresholds: [],
     thresholds: [],
     unit: 'none',
     unit: 'none',
     stat: 'avg',
     stat: 'avg',
-    theme: GrafanaThemeType.Dark,
   };
   };
 
 
   componentDidMount() {
   componentDidMount() {
@@ -134,7 +133,7 @@ export class Gauge extends PureComponent<Props> {
       Math.min(dimension / 5, 100) * (formattedValue !== null ? this.getFontScale(formattedValue.length) : 1);
       Math.min(dimension / 5, 100) * (formattedValue !== null ? this.getFontScale(formattedValue.length) : 1);
     const thresholdLabelFontSize = fontSize / 2.5;
     const thresholdLabelFontSize = fontSize / 2.5;
 
 
-    const options = {
+    const options: any = {
       series: {
       series: {
         gauges: {
         gauges: {
           gauge: {
           gauge: {

+ 2 - 2
public/app/core/components/jsontree/jsontree.ts

@@ -10,13 +10,13 @@ coreModule.directive('jsonTree', [
         startExpanded: '@',
         startExpanded: '@',
         rootName: '@',
         rootName: '@',
       },
       },
-      link: (scope, elem) => {
+      link: (scope: any, elem) => {
         const jsonExp = new JsonExplorer(scope.object, 3, {
         const jsonExp = new JsonExplorer(scope.object, 3, {
           animateOpen: true,
           animateOpen: true,
         });
         });
 
 
         const html = jsonExp.render(true);
         const html = jsonExp.render(true);
-        elem.html(html);
+        elem.replaceAll(html);
       },
       },
     };
     };
   },
   },

+ 1 - 1
public/app/core/directives/give_focus.ts

@@ -14,7 +14,7 @@ coreModule.directive('giveFocus', () => {
         }
         }
         setTimeout(() => {
         setTimeout(() => {
           element.focus();
           element.focus();
-          const domEl = element[0];
+          const domEl: any = element[0];
           if (domEl.setSelectionRange) {
           if (domEl.setSelectionRange) {
             const pos = element.val().length * 2;
             const pos = element.val().length * 2;
             domEl.setSelectionRange(pos, pos);
             domEl.setSelectionRange(pos, pos);

+ 1 - 1
public/app/features/datasources/settings/HttpSettingsCtrl.ts

@@ -9,7 +9,7 @@ coreModule.directive('datasourceHttpSettings', () => {
     },
     },
     templateUrl: 'public/app/features/datasources/partials/http_settings.html',
     templateUrl: 'public/app/features/datasources/partials/http_settings.html',
     link: {
     link: {
-      pre: ($scope, elem, attrs) => {
+      pre: ($scope: any, elem, attrs) => {
         // do not show access option if direct access is disabled
         // do not show access option if direct access is disabled
         $scope.showAccessOption = $scope.noDirectAccess !== 'true';
         $scope.showAccessOption = $scope.noDirectAccess !== 'true';
         $scope.showAccessHelp = false;
         $scope.showAccessHelp = false;

+ 2 - 2
public/app/features/panel/panel_directive.ts

@@ -33,7 +33,7 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
     template: panelTemplate,
     template: panelTemplate,
     transclude: true,
     transclude: true,
     scope: { ctrl: '=' },
     scope: { ctrl: '=' },
-    link: (scope, elem) => {
+    link: (scope: any, elem) => {
       const panelContainer = elem.find('.panel-container');
       const panelContainer = elem.find('.panel-container');
       const panelContent = elem.find('.panel-content');
       const panelContent = elem.find('.panel-content');
       const cornerInfoElem = elem.find('.panel-info-corner');
       const cornerInfoElem = elem.find('.panel-info-corner');
@@ -67,7 +67,7 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
       // set initial transparency
       // set initial transparency
       if (ctrl.panel.transparent) {
       if (ctrl.panel.transparent) {
         transparentLastState = true;
         transparentLastState = true;
-        panelContainer.addClass('panel-transparent', true);
+        panelContainer.addClass('panel-transparent');
       }
       }
 
 
       // update scrollbar after mounting
       // update scrollbar after mounting

+ 21 - 24
public/app/plugins/datasource/stackdriver/query_filter_ctrl.ts

@@ -2,28 +2,6 @@ import coreModule from 'app/core/core_module';
 import _ from 'lodash';
 import _ from 'lodash';
 import { FilterSegments, DefaultFilterValue } from './filter_segments';
 import { FilterSegments, DefaultFilterValue } from './filter_segments';
 
 
-export class StackdriverFilter {
-  /** @ngInject */
-  constructor() {
-    return {
-      templateUrl: 'public/app/plugins/datasource/stackdriver/partials/query.filter.html',
-      controller: 'StackdriverFilterCtrl',
-      controllerAs: 'ctrl',
-      bindToController: true,
-      restrict: 'E',
-      scope: {
-        labelData: '<',
-        loading: '<',
-        groupBys: '<',
-        filters: '<',
-        filtersChanged: '&',
-        groupBysChanged: '&',
-        hideGroupBys: '<',
-      },
-    };
-  }
-}
-
 export class StackdriverFilterCtrl {
 export class StackdriverFilterCtrl {
   defaultRemoveGroupByValue = '-- remove group by --';
   defaultRemoveGroupByValue = '-- remove group by --';
   resourceTypeValue = 'resource.type';
   resourceTypeValue = 'resource.type';
@@ -193,5 +171,24 @@ export class StackdriverFilterCtrl {
   }
   }
 }
 }
 
 
-coreModule.directive('stackdriverFilter', StackdriverFilter);
-coreModule.controller('StackdriverFilterCtrl', StackdriverFilterCtrl);
+/** @ngInject */
+function stackdriverFilter() {
+  return {
+    templateUrl: 'public/app/plugins/datasource/stackdriver/partials/query.filter.html',
+    controller: StackdriverFilterCtrl,
+    controllerAs: 'ctrl',
+    bindToController: true,
+    restrict: 'E',
+    scope: {
+      labelData: '<',
+      loading: '<',
+      groupBys: '<',
+      filters: '<',
+      filtersChanged: '&',
+      groupBysChanged: '&',
+      hideGroupBys: '<',
+    },
+  };
+}
+
+coreModule.directive('stackdriverFilter', stackdriverFilter);

+ 2 - 2
public/app/plugins/panel/heatmap/color_legend.ts

@@ -19,7 +19,7 @@ coreModule.directive('colorLegend', () => {
   return {
   return {
     restrict: 'E',
     restrict: 'E',
     template: '<div class="heatmap-color-legend"><svg width="16.5rem" height="24px"></svg></div>',
     template: '<div class="heatmap-color-legend"><svg width="16.5rem" height="24px"></svg></div>',
-    link: (scope, elem, attrs) => {
+    link: (scope: any, elem, attrs) => {
       const ctrl = scope.ctrl;
       const ctrl = scope.ctrl;
       const panel = scope.ctrl.panel;
       const panel = scope.ctrl.panel;
 
 
@@ -55,7 +55,7 @@ coreModule.directive('heatmapLegend', () => {
   return {
   return {
     restrict: 'E',
     restrict: 'E',
     template: `<div class="heatmap-color-legend"><svg width="${LEGEND_WIDTH_PX}px" height="${LEGEND_HEIGHT_PX}px"></svg></div>`,
     template: `<div class="heatmap-color-legend"><svg width="${LEGEND_WIDTH_PX}px" height="${LEGEND_HEIGHT_PX}px"></svg></div>`,
-    link: (scope, elem, attrs) => {
+    link: (scope: any, elem, attrs) => {
       const ctrl = scope.ctrl;
       const ctrl = scope.ctrl;
       const panel = scope.ctrl.panel;
       const panel = scope.ctrl.panel;
 
 

+ 5 - 0
yarn.lock

@@ -1514,6 +1514,11 @@
     react-input-autosize "^2.2.1"
     react-input-autosize "^2.2.1"
     react-transition-group "^2.2.1"
     react-transition-group "^2.2.1"
 
 
+"@types/angular@^1.6.6":
+  version "1.6.54"
+  resolved "https://registry.yarnpkg.com/@types/angular/-/angular-1.6.54.tgz#f9d5a03e4da7b021a6dabe5d63e899ed4567a5bd"
+  integrity sha512-xA1FuozWXeRQ7FClUbvk8ePL+dydBeDoCWRPFTHU5+8uvVtIIfLGiHA8CMkwsbddFCYnTDVbLxG85a/HBx7LtA==
+
 "@types/chalk@^2.2.0":
 "@types/chalk@^2.2.0":
   version "2.2.0"
   version "2.2.0"
   resolved "https://registry.yarnpkg.com/@types/chalk/-/chalk-2.2.0.tgz#b7f6e446f4511029ee8e3f43075fb5b73fbaa0ba"
   resolved "https://registry.yarnpkg.com/@types/chalk/-/chalk-2.2.0.tgz#b7f6e446f4511029ee8e3f43075fb5b73fbaa0ba"