Skip to content

Commit

Permalink
Partially use strict types mode, no implicitly Any
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed May 8, 2019
1 parent 0d9d84b commit e6d42e0
Show file tree
Hide file tree
Showing 209 changed files with 2,771 additions and 1,612 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"esversion": 6,
"-W014": true
"-W014": true,
"-W119": true
}
35 changes: 23 additions & 12 deletions api/src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import * as themes from './Themes.js';
* @property {boolean} [addMiniMap=false]
* @property {boolean} [miniMapExpanded=true]
* @property {boolean} [addLayerSwitcher=false]
* @property {Array<string>} [layers]
* @property {string[]} [layers]
*/

/**
Expand All @@ -64,16 +64,20 @@ class Map {
* @param {MapOptions} options API options.
*/
constructor(options) {
/** @type {import('ol/View.js').ViewOptions} */
const viewOptions = {
projection: getProjection(constants.projection),
resolutions: constants.resolutions,
zoom: options.zoom !== undefined ? options.zoom : 10
};
if (constants.extent) {
viewOptions.extent = constants.extent;
}
/**
* @private
* @type {View}
*/
this.view_ = new View({
projection: getProjection(constants.projection),
extent: constants.extent,
resolutions: constants.resolutions,
zoom: options.zoom !== undefined ? options.zoom : 10
});
this.view_ = new View(viewOptions);

if (options.center !== undefined) {
this.view_.setCenter(options.center);
Expand Down Expand Up @@ -306,7 +310,12 @@ class Map {
let anchor;
if (values.iconOffset) {
// flip the sign of the value to be compatible with the old api.
anchor = values.iconOffset.split(',').map(parseFloat).map(val => val * Math.sign(val));
anchor = values.iconOffset.split(',').map(parseFloat).map(
/**
* @param {number} val
*/
val => val * Math.sign(val)
);
}
const image = new Icon({
src: values.icon,
Expand Down Expand Up @@ -366,13 +375,14 @@ class Map {


/**
* @param {Array.<string>} keys Keys.
* @param {Array.<*>} values Values.
* @param {Array<string>} keys Keys.
* @param {Array<*>} values Values.
* @returns {Object<string, *>} Object.
* @private
* @hidden
*/
function zip(keys, values) {
/** @type {Object<string, *>} */
const obj = {};
keys.forEach((key, index) => {
obj[key] = values[index];
Expand All @@ -382,13 +392,14 @@ function zip(keys, values) {


/**
* @param {Object.<string, *>} obj Object.
* @param {Array.<string>} keys keys.
* @param {Object<string, *>} obj Object.
* @param {Array<string>} keys keys.
* @returns {Object<string, *>} Object.
* @private
* @hidden
*/
function filterByKeys(obj, keys) {
/** @type {Object<string, *>} */
const filtered = {};
keys.forEach((key) => {
filtered[key] = obj[key];
Expand Down
2 changes: 1 addition & 1 deletion api/src/Querent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function getFeaturesFromLayer(layer, ids) {
return new Promise((resolve, reject) => {
getOverlayDefs().then((overlayDefs) => {

/** Array<import('ol/Feature.js').default> */
/** @type {Array<import('ol/Feature.js').default>} */
let features = [];
const overlayDef = overlayDefs.get(layer);

Expand Down
4 changes: 2 additions & 2 deletions api/src/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const capabilities = new Map();
* @private
* @hidden
* @param {string} url The URL
* @return {Object} Any
* @return {Promise<Object>} Any
*/
function getWMTSCapability(url) {
if (!(url in capabilities)) {
Expand All @@ -254,5 +254,5 @@ function getWMTSCapability(url) {
});
capabilities.set(url, request);
}
return capabilities.get(url);
return /** @type {Promise<Object>} */(capabilities.get(url));
}
4 changes: 2 additions & 2 deletions api/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js';
* @property {string} backgroundLayer
*/

export default {
export default /** @type {APIConfig} */({
// The URL to the themes service.
themesUrl: 'https://www.example.com',

Expand All @@ -28,4 +28,4 @@ export default {
// The name of the GeoMapFish layer to use as background. May be a single value
// (WMTS) or a comma-separated list of layer names (WMS).
backgroundLayer: 'orthophoto',
};
});
14 changes: 10 additions & 4 deletions contribs/gmf/apps/desktop/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,16 @@ const module = angular.module('Appdesktop', [
]);

module.value('gmfContextualdatacontentTemplateUrl', 'gmf/contextualdata');
module.run(/* @ngInject */ ($templateCache) => {
// @ts-ignore: webpack
$templateCache.put('gmf/contextualdata', require('./contextualdata.html'));
});
module.run(
/**
* @ngInject
* @param {angular.ITemplateCacheService} $templateCache
*/
($templateCache) => {
// @ts-ignore: webpack
$templateCache.put('gmf/contextualdata', require('./contextualdata.html'));
}
);

module.controller('DesktopController', Controller);

Expand Down
13 changes: 9 additions & 4 deletions contribs/gmf/apps/oeedit/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,15 @@ const module = angular.module('Appoeedit', [
]);

module.value('gmfContextualdatacontentTemplateUrl', 'gmf/contextualdata');
module.run(/* @ngInject */ ($templateCache) => {
// @ts-ignore: webpack
$templateCache.put('gmf/contextualdata', require('./contextualdata.html'));
});
module.run(
/**
* @ngInject
* @param {angular.ITemplateCacheService} $templateCache
*/
($templateCache) => {
// @ts-ignore: webpack
$templateCache.put('gmf/contextualdata', require('./contextualdata.html'));
});

module.value('gmfPermalinkOptions', /** @type {PermalinkOptions} */ ({
pointRecenterZoom: 10
Expand Down
10 changes: 8 additions & 2 deletions contribs/gmf/examples/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.constant('angularLocaleScript', '../build/angular-locale_{{locale}}.js');

/**
* @constructor
* @param {!angular.IScope} $scope Angular scope.
* @param {!import("ngeo/misc/WMSTime.js").WMSTime} ngeoWMSTime wmstime service.
* @param {angular.IScope} $scope Angular scope.
* @param {import("ngeo/misc/WMSTime.js").WMSTime} ngeoWMSTime wmstime service.
* @ngInject
*/
function MainController($scope, ngeoWMSTime) {
Expand Down Expand Up @@ -68,10 +68,16 @@ function MainController($scope, ngeoWMSTime) {
*/
this.rangeValue = '';

/**
* @param {import('ngeo/datasource/OGC.js').TimeRange} date
*/
this.onDateSelected = function(date) {
this.value = this.ngeoWMSTime_.formatWMSTimeParam(this.wmsTimeValueMode, date);
};

/**
* @param {import('ngeo/datasource/OGC.js').TimeRange} date
*/
this.onDateRangeSelected = function(date) {
this.rangeValue = this.ngeoWMSTime_.formatWMSTimeParam(this.wmsTimeRangeMode, date);
};
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/editfeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ MainController.prototype.deleteFeature = function() {

/**
* Called after an insert, update or delete request.
* @param {angular.IHttpResponse} resp Ajax response.
* @param {angular.IHttpResponse<void>} resp Ajax response.
* @private
*/
MainController.prototype.handleEditFeature_ = function(resp) {
Expand Down
2 changes: 1 addition & 1 deletion contribs/gmf/examples/editfeatureselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.constant('angularLocaleScript', '../build/angular-locale_{{locale}}.js');


/**
* @param {!angular.IScope} $scope Angular scope.
* @param {angular.IScope} $scope Angular scope.
* @param {import("gmf/theme/Themes.js").ThemesService} gmfThemes The gmf themes service.
* @param {import("gmf/layertree/TreeManager.js").LayertreeTreeManager} gmfTreeManager gmf Tree Manager
* service.
Expand Down
7 changes: 7 additions & 0 deletions contribs/gmf/examples/featurestyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function MainController($scope, ngeoFeatureHelper) {
// create features
const features = [];

/** @type {Object<string, *>} */
const pointProperties = {
geometry: new olGeomPoint([-8458215, 6672646])
};
Expand All @@ -71,6 +72,7 @@ function MainController($scope, ngeoFeatureHelper) {
pointProperties[ngeoFormatFeatureProperties.SIZE] = '6';
features.push(new olFeature(pointProperties));

/** @type {Object<string, *>} */
const textProperties = {
geometry: new olGeomPoint([-8007848, 6209744])
};
Expand All @@ -82,6 +84,7 @@ function MainController($scope, ngeoFeatureHelper) {
textProperties[ngeoFormatFeatureProperties.STROKE] = '2';
features.push(new olFeature(textProperties));

/** @type {Object<string, *>} */
const lineProperties = {
geometry: new olGeomLineString([
[-8321240, 6523441],
Expand All @@ -95,6 +98,7 @@ function MainController($scope, ngeoFeatureHelper) {
lineProperties[ngeoFormatFeatureProperties.STROKE] = '4';
features.push(new olFeature(lineProperties));

/** @type {Object<string, *>} */
const poly1Properties = {
geometry: new olGeomPolygon([
[
Expand All @@ -113,6 +117,7 @@ function MainController($scope, ngeoFeatureHelper) {
poly1Properties[ngeoFormatFeatureProperties.STROKE] = '1';
features.push(new olFeature(poly1Properties));

/** @type {Object<string, *>} */
const poly2Properties = {
geometry: new olGeomPolygon([
[
Expand All @@ -130,6 +135,7 @@ function MainController($scope, ngeoFeatureHelper) {
poly2Properties[ngeoFormatFeatureProperties.STROKE] = '3';
features.push(new olFeature(poly2Properties));

/** @type {Object<string, *>} */
const rectProperties = {
geometry: olGeomPolygonFromExtent([-7874848, 6496535, -7730535, 6384020])
};
Expand All @@ -140,6 +146,7 @@ function MainController($scope, ngeoFeatureHelper) {
rectProperties[ngeoFormatFeatureProperties.STROKE] = '2';
features.push(new olFeature(rectProperties));

/** @type {Object<string, *>} */
const circleProperties = {
geometry: olGeomPolygonFromCircle(
new olGeomCircle([-7691093, 6166327], 35000), 64)
Expand Down
9 changes: 6 additions & 3 deletions contribs/gmf/examples/layertree.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation
this.themes = themes;

// Get an array with all nodes entities existing in "themes".
/** @type {Array<import('gmf/themes.js').GmfTheme|import('gmf/themes.js').GmfGroup|import('gmf/themes.js').GmfLayer>} */
const flatNodes = [];
this.themes.forEach((theme) => {
theme.children.forEach((group) => {
Expand All @@ -165,9 +166,10 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation
});
});
flatNodes.forEach((node) => {
const groupNode = /** @type {import('gmf/themes.js').GmfGroup} */(node);
// Get an array of all layers
if (node.children === undefined) {
this.layers.push(node);
if (groupNode.children === undefined) {
this.layers.push(/** @type {import('gmf/themes.js').GmfLayer} */(node));
}
});
}
Expand All @@ -191,7 +193,8 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation
let alreadyAdded = false;
nodes.some((n) => {
if (n.id === node.id) {
return alreadyAdded = true;
alreadyAdded = true;
return true;
}
return false;
});
Expand Down
6 changes: 4 additions & 2 deletions contribs/gmf/examples/layertreeadd.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation
this.themes = themes;

// Get an array with all nodes entities existing in "themes".
/** @type {Array<import('gmf/themes.js').GmfTheme|import('gmf/themes.js').GmfGroup|import('gmf/themes.js').GmfLayer>} */
const flatNodes = [];
this.themes.forEach((theme) => {
theme.children.forEach((group) => {
Expand All @@ -165,9 +166,10 @@ function MainController(gmfTreeManager, gmfThemes, gmfThemeManager, ngeoLocation
});
});
flatNodes.forEach((node) => {
const groupNode = /** @type {import('gmf/themes.js').GmfGroup} */(node);
// Get an array of all layers
if (node.children === undefined) {
this.layers.push(node);
if (groupNode.children === undefined) {
this.layers.push(/** @type {import('gmf/themes.js').GmfLayer} */(node));
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions contribs/gmf/examples/objecteditinghub.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ MainController.prototype.runEditor = function() {
console.assert(property !== undefined);
const id = feature.get(property);

/** @type {Object<string, *>} */
const params = {};
params[ObjecteditingParam.GEOM_TYPE] = geomType;
params[ObjecteditingParam.ID] = id;
Expand All @@ -251,7 +252,7 @@ MainController.prototype.runEditor = function() {

/**
* @param {import('gmf/themes.js').GmfLayerWMS} gmfLayerNode Layer node.
* @return {angular.IPromise} The promise attached to the deferred object.
* @return {angular.IPromise<void>} The promise attached to the deferred object.
* @private
*/
MainController.prototype.getFeatures_ = function(gmfLayerNode) {
Expand Down Expand Up @@ -328,7 +329,7 @@ MainController.prototype.getFeaturesFromCache_ = function(gmfLayerNode) {

/**
* @param {import('gmf/themes.js').GmfLayerWMS} gmfLayerNode Layer node.
* @return {angular.IPromise} The promise attached to the deferred object.
* @return {angular.IPromise<void>} The promise attached to the deferred object.
* @private
*/
MainController.prototype.getGeometryType_ = function(gmfLayerNode) {
Expand Down Expand Up @@ -410,6 +411,7 @@ MainController.prototype.getGeometryTypeFromCache_ = function(
* @return {string} The new URI.
*/
MainController.appendParams = function(uri, params) {
/** @type {string[]} */
const keyParams = [];
// Skip any null or undefined parameter values
Object.keys(params).forEach((k) => {
Expand Down
6 changes: 6 additions & 0 deletions contribs/gmf/examples/timeslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ function MainController($scope, ngeoWMSTime) {
*/
this.sliderRangeValue = '';

/**
* @param {import('ngeo/datasource/OGC.js').TimeRange} date
*/
this.onDateSelected = function(date) {
this.sliderValue = this.ngeoWMSTime_.formatWMSTimeParam(this.wmsTimeValueMode, date);
$scope.$digest();
};

/**
* @param {import('ngeo/datasource/OGC.js').TimeRange} date
*/
this.onDateRangeSelected = function(date) {
this.sliderRangeValue = this.ngeoWMSTime_.formatWMSTimeParam(this.wmsTimeRangeMode, date);
$scope.$digest();
Expand Down
1 change: 1 addition & 0 deletions contribs/gmf/examples/url.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**
* @type {Object<string, string>}
*/
const exports = {};

Expand Down

0 comments on commit e6d42e0

Please sign in to comment.