typescript: stricter typescript option

This commit is contained in:
Torkel Ödegaard
2017-09-26 11:24:58 +02:00
parent ff108bd871
commit 7b42e13c79
12 changed files with 72 additions and 55 deletions

View File

@@ -106,6 +106,8 @@ function getStateDisplayModel(state) {
}; };
} }
} }
throw {message: 'Unknown alert state'};
} }
function joinEvalMatches(matches, separator: string) { function joinEvalMatches(matches, separator: string) {

View File

@@ -84,7 +84,7 @@ export class AlertTabCtrl {
}); });
} }
getNotificationIcon(type) { getNotificationIcon(type): string {
switch (type) { switch (type) {
case "email": return "fa fa-envelope"; case "email": return "fa fa-envelope";
case "slack": return "fa fa-slack"; case "slack": return "fa fa-slack";
@@ -95,6 +95,7 @@ export class AlertTabCtrl {
case "hipchat": return "fa fa-mail-forward"; case "hipchat": return "fa fa-mail-forward";
case "pushover": return "fa fa-mobile"; case "pushover": return "fa fa-mobile";
} }
return 'fa fa-bell';
} }
getNotifications() { getNotifications() {

View File

@@ -69,10 +69,11 @@ export class QueryTroubleshooterCtrl {
} }
} }
getClipboardText() { getClipboardText(): string {
if (this.jsonExplorer) { if (this.jsonExplorer) {
return JSON.stringify(this.jsonExplorer.json, null, 2); return JSON.stringify(this.jsonExplorer.json, null, 2);
} }
return '';
} }
onRequestResponse(data) { onRequestResponse(data) {

View File

@@ -38,6 +38,8 @@ export class DashImportListCtrl {
}); });
}, 500); }, 500);
}); });
} else {
return Promise.resolve();
} }
}); });
} }

View File

@@ -79,6 +79,7 @@ export class PluginEditCtrl {
case 'app': return 'icon-gf icon-gf-apps'; case 'app': return 'icon-gf icon-gf-apps';
case 'page': return 'icon-gf icon-gf-endpoint-tiny'; case 'page': return 'icon-gf icon-gf-endpoint-tiny';
case 'dashboard': return 'icon-gf icon-gf-dashboard'; case 'dashboard': return 'icon-gf icon-gf-dashboard';
default: return 'icon-gf icon-gf-apps';
} }
} }

View File

@@ -54,7 +54,7 @@ export class VariableEditorCtrl {
$scope.isValid = function() { $scope.isValid = function() {
if (!$scope.ctrl.form.$valid) { if (!$scope.ctrl.form.$valid) {
return; return false;
} }
if (!$scope.current.name.match(/^\w+$/)) { if (!$scope.current.name.match(/^\w+$/)) {

View File

@@ -352,12 +352,13 @@ export class InfluxQueryCtrl extends QueryCtrl {
this.panelCtrl.refresh(); this.panelCtrl.refresh();
} }
getTagValueOperator(tagValue, tagOperator) { getTagValueOperator(tagValue, tagOperator): string {
if (tagOperator !== '=~' && tagOperator !== '!~' && /^\/.*\/$/.test(tagValue)) { if (tagOperator !== '=~' && tagOperator !== '!~' && /^\/.*\/$/.test(tagValue)) {
return '=~'; return '=~';
} else if ((tagOperator === '=~' || tagOperator === '!~') && /^(?!\/.*\/$)/.test(tagValue)) { } else if ((tagOperator === '=~' || tagOperator === '!~') && /^(?!\/.*\/$)/.test(tagValue)) {
return '='; return '=';
} }
return null;
} }
getCollapsedText() { getCollapsedText() {

View File

@@ -142,34 +142,34 @@ export class DataProcessor {
let fields = []; let fields = [];
var firstItem = dataList[0]; var firstItem = dataList[0];
let fieldParts = []; let fieldParts = [];
function getPropertiesRecursive(obj) { function getPropertiesRecursive(obj) {
_.forEach(obj, (value, key) => { _.forEach(obj, (value, key) => {
if (_.isObject(value)) { if (_.isObject(value)) {
fieldParts.push(key); fieldParts.push(key);
getPropertiesRecursive(value); getPropertiesRecursive(value);
} else { } else {
if (!onlyNumbers || _.isNumber(value)) { if (!onlyNumbers || _.isNumber(value)) {
let field = fieldParts.concat(key).join('.'); let field = fieldParts.concat(key).join('.');
fields.push(field); fields.push(field);
}
} }
}); }
fieldParts.pop(); });
fieldParts.pop();
} }
if (firstItem.type === 'docs') { if (firstItem.type === 'docs') {
if (firstItem.datapoints.length === 0) { if (firstItem.datapoints.length === 0) {
return []; return [];
} }
getPropertiesRecursive(firstItem.datapoints[0]); getPropertiesRecursive(firstItem.datapoints[0]);
return fields;
} }
return fields;
} }
getXAxisValueOptions(options) { getXAxisValueOptions(options) {
switch (this.panel.xaxis.mode) { switch (this.panel.xaxis.mode) {
case 'time': {
return [];
}
case 'series': { case 'series': {
return [ return [
{text: 'Avg', value: 'avg'}, {text: 'Avg', value: 'avg'},
@@ -180,6 +180,8 @@ export class DataProcessor {
]; ];
} }
} }
return [];
} }
pluckDeep(obj: any, property: string) { pluckDeep(obj: any, property: string) {

View File

@@ -120,6 +120,8 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv, popoverSrv) {
if (panelWidth === 0) { if (panelWidth === 0) {
return true; return true;
} }
return false;
} }
function drawHook(plot) { function drawHook(plot) {
@@ -385,6 +387,7 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv, popoverSrv) {
if (legendSideLastValue !== null && panel.legend.rightSide !== legendSideLastValue) { if (legendSideLastValue !== null && panel.legend.rightSide !== legendSideLastValue) {
return true; return true;
} }
return false;
} }
function addTimeAxis(options) { function addTimeAxis(options) {

View File

@@ -21,7 +21,7 @@ function elasticHistogramToHeatmap(seriesList) {
for (let series of seriesList) { for (let series of seriesList) {
let bound = Number(series.alias); let bound = Number(series.alias);
if (isNaN(bound)) { if (isNaN(bound)) {
return; return heatmap;
} }
for (let point of series.datapoints) { for (let point of series.datapoints) {
@@ -384,36 +384,40 @@ function isHeatmapDataEqual(objA: any, objB: any): boolean {
let is_eql = !emptyXOR(objA, objB); let is_eql = !emptyXOR(objA, objB);
_.forEach(objA, (xBucket: XBucket, x) => { _.forEach(objA, (xBucket: XBucket, x) => {
if (objB[x]) { if (objB[x]) {
if (emptyXOR(xBucket.buckets, objB[x].buckets)) { if (emptyXOR(xBucket.buckets, objB[x].buckets)) {
is_eql = false;
return false;
}
_.forEach(xBucket.buckets, (yBucket: YBucket, y) => {
if (objB[x].buckets && objB[x].buckets[y]) {
if (objB[x].buckets[y].values) {
is_eql = _.isEqual(_.sortBy(yBucket.values), _.sortBy(objB[x].buckets[y].values));
if (!is_eql) {
return false;
}
} else {
is_eql = false;
return false;
}
} else {
is_eql = false;
return false;
}
});
if (!is_eql) {
return false;
}
} else {
is_eql = false; is_eql = false;
return false; return false;
} }
_.forEach(xBucket.buckets, (yBucket: YBucket, y) => {
if (objB[x].buckets && objB[x].buckets[y]) {
if (objB[x].buckets[y].values) {
is_eql = _.isEqual(_.sortBy(yBucket.values), _.sortBy(objB[x].buckets[y].values));
if (!is_eql) {
return false;
} else {
return true;
}
} else {
is_eql = false;
return false;
}
} else {
is_eql = false;
return false;
}
});
if (!is_eql) {
return false;
} else {
return true;
}
} else {
is_eql = false;
return false;
}
}); });
return is_eql; return is_eql;
@@ -425,11 +429,11 @@ function emptyXOR(foo: any, bar: any): boolean {
export { export {
convertToHeatMap, convertToHeatMap,
elasticHistogramToHeatmap, elasticHistogramToHeatmap,
convertToCards, convertToCards,
mergeZeroBuckets, mergeZeroBuckets,
getMinLog, getMinLog,
getValueBucketBound, getValueBucketBound,
isHeatmapDataEqual, isHeatmapDataEqual,
calculateBucketSize calculateBucketSize
}; };

View File

@@ -137,6 +137,7 @@ transformers['table'] = {
if (!data || data.length === 0) { if (!data || data.length === 0) {
return []; return [];
} }
return data[0].columns;
}, },
transform: function(data, panel, model) { transform: function(data, panel, model) {
if (!data || data.length === 0) { if (!data || data.length === 0) {

View File

@@ -12,7 +12,7 @@
"noEmitOnError": false, "noEmitOnError": false,
"emitDecoratorMetadata": false, "emitDecoratorMetadata": false,
"experimentalDecorators": false, "experimentalDecorators": false,
"noImplicitReturns": false, "noImplicitReturns": true,
"noImplicitThis": false, "noImplicitThis": false,
"noImplicitUseStrict":false, "noImplicitUseStrict":false,
"moduleResolution": "classic" "moduleResolution": "classic"
@@ -26,5 +26,4 @@
"public/vendor/**/*", "public/vendor/**/*",
"public/**/*.d.ts" "public/**/*.d.ts"
] ]
} }