Skip to content

Commit

Permalink
Fix some types
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Jan 24, 2019
1 parent 67116b9 commit 3aa8f10
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 36 deletions.
4 changes: 2 additions & 2 deletions contribs/gmf/src/mobile/measure/pointComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.directive('gmfMobileMeasurepoint', component);
* @param {!angular.IScope} $scope Angular scope.
* @param {angular.IFilterService} $filter Angular filter service.
* @param {import("gmf/raster/RasterService.js").default} gmfRaster gmf Raster service.
* @param {import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce ngeo Debounce factory.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce ngeo Debounce factory.
* @constructor
* @private
* @ngInject
Expand All @@ -121,7 +121,7 @@ function Controller(gettextCatalog, $scope, $filter, gmfRaster, ngeoDebounce) {
this.gmfRaster_ = gmfRaster;

/**
* @type {import("ngeo/misc/debounce.js").miscDebounce}
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(): void>}
* @private
*/
this.ngeoDebounce_ = ngeoDebounce;
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/permalink/Permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const ParamPrefix = {
* @param {angular.ITimeoutService} $timeout Angular timeout service.
* @param {angular.IScope} $rootScope Angular rootScope.
* @param {angular.auto.IInjectorService} $injector Main injector.
* @param {import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce ngeo Debounce factory.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce ngeo Debounce factory.
* @param {angular.gettext.gettextCatalog} gettextCatalog Gettext service.
* @param {import("ngeo/misc/EventHelper.js").default} ngeoEventHelper Ngeo event helper service
* @param {import("ngeo/statemanager/Service.js").default} ngeoStateManager The ngeo statemanager service.
Expand Down Expand Up @@ -145,7 +145,7 @@ function Permalink($q, $timeout, $rootScope, $injector, ngeoDebounce, gettextCat
// == properties from params ==

/**
* @type {import("ngeo/misc/debounce.js").miscDebounce}
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(): void>}
* @private
*/
this.ngeoDebounce_ = ngeoDebounce;
Expand Down
4 changes: 2 additions & 2 deletions contribs/gmf/src/raster/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ module.directive('gmfElevation', component);
* @hidden
* @param {!angular.IScope} $scope Scope.
* @param {!angular.IFilterService} $filter Angular filter.
* @param {!import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce Ngeo debounce factory
* @param {!import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce Ngeo debounce factory
* @param {!import("gmf/raster/RasterService.js").default} gmfRaster Gmf Raster service
* @param {!angular.gettext.gettextCatalog} gettextCatalog Gettext catalog.
* @constructor
Expand All @@ -143,7 +143,7 @@ function Controller($scope, $filter, ngeoDebounce, gmfRaster, gettextCatalog) {
this.filter_ = $filter;

/**
* @type {import("ngeo/misc/debounce.js").miscDebounce}
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(): void>}
* @private
*/
this.ngeoDebounce_ = ngeoDebounce;
Expand Down
4 changes: 2 additions & 2 deletions examples/permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.component('appMap', mapComponent);

/**
* @param {import("ngeo/statemanager/Location.js").default} ngeoLocation ngeo Location service.
* @param {import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce ngeo Debounce factory.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce ngeo Debounce factory.
* @constructor
* @ngInject
*/
Expand All @@ -66,7 +66,7 @@ function MapComponentController(ngeoLocation, ngeoDebounce) {
this.ngeoLocation_ = ngeoLocation;

/**
* @type {import("ngeo/misc/debounce.js").miscDebounce}
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(): void>}
* @private
*/
this.ngeoDebounce_ = ngeoDebounce;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@geoblocks/proj": "0.3.0",
"@openlayers/eslint-plugin": "4.0.0-beta.2",
"@types/angular": "1.6.53",
"@types/angular-gettext": "2.1.34",
"@types/angular-gettext": "^2.1.34",
"@types/cesium": "^1.47.3",
"@types/d3": "5.7.0",
"@types/jquery": "3.3.29",
Expand Down
7 changes: 4 additions & 3 deletions src/CustomEvent.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import olEventsEvent from 'ol/events/Event.js';


/**
* @template T
*/
export default class extends olEventsEvent {
/**
* @constructor
* @param {string} type Event type.
* @param {T} detail Event Detail.
* @template T
*/
constructor(type, detail = {}) {
constructor(type, detail = /** @type {T} */({})) {
super(type);

/**
Expand Down
8 changes: 8 additions & 0 deletions src/misc/FeatureHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ FeatureHelper.prototype.getLineStringStyle_ = function(feature) {
const textLabelValue = textLabelValues.join('\n');
styles.push(new olStyleStyle({
text: this.createTextStyle_({
propertyName: '',
name: '',
text: textLabelValue
})
Expand Down Expand Up @@ -298,6 +299,7 @@ FeatureHelper.prototype.getPointStyle_ = function(feature) {
const point_to_px = 1.3;
styles.push(new olStyleStyle({
text: this.createTextStyle_({
propertyName: '',
name: '',
text: textLabelValue,
size: font_size,
Expand Down Expand Up @@ -391,6 +393,7 @@ FeatureHelper.prototype.getPolygonStyle_ = function(feature) {
width: strokeWidth
}),
text: this.createTextStyle_({
propertyName: '',
name: '',
text: length,
angle: ((azimut % 180) + 180) % 180 - 90
Expand All @@ -401,6 +404,7 @@ FeatureHelper.prototype.getPolygonStyle_ = function(feature) {
styles.push(new olStyleStyle({
geometry: new olGeomPoint(line.getLastCoordinate()),
text: this.createTextStyle_({
propertyName: '',
name: '',
text: `${this.numberFormat_(azimut, this.decimals_)}°`,
size: 10,
Expand All @@ -413,6 +417,7 @@ FeatureHelper.prototype.getPolygonStyle_ = function(feature) {
if (showLabel) {
styles.push(new olStyleStyle({
text: this.createTextStyle_({
propertyName: '',
name: '',
text: this.getNameProperty(feature),
offsetY: -8,
Expand All @@ -434,6 +439,7 @@ FeatureHelper.prototype.getPolygonStyle_ = function(feature) {
const textLabelValue = textLabelValues.join('\n');
styles.push(new olStyleStyle({
text: this.createTextStyle_({
propertyName: '',
name: '',
text: textLabelValue,
exceedLength: true
Expand All @@ -455,6 +461,7 @@ FeatureHelper.prototype.getTextStyle_ = function(feature) {

return new olStyleStyle({
text: this.createTextStyle_({
propertyName: '',
name: '',
text: this.getNameProperty(feature),
size: this.getSizeProperty(feature),
Expand Down Expand Up @@ -881,6 +888,7 @@ FeatureHelper.prototype.getHaloStyle_ = function(feature) {
case ngeoGeometryType.TEXT:
style = new olStyleStyle({
text: this.createTextStyle_({
propertyName: '',
name: '',
text: this.getNameProperty(feature),
size: this.getSizeProperty(feature),
Expand Down
2 changes: 1 addition & 1 deletion src/misc/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import angular from 'angular';
* @constructor
* @param {angular.IQService} $q .
* @param {angular.IHttpService} $http .
* @param {gettext} gettext .
* @param {angular.gettext.gettextFunction} gettext .
* @ngInject
*/
function File($q, $http, gettext) {
Expand Down
15 changes: 8 additions & 7 deletions src/misc/debounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import angular from 'angular';
const module = angular.module('ngeoDebounce', []);

/**
* Provides a debounce function used to debounce calls to a user-provided
* function.
* @typedef {function(function, number, boolean):function} miscDebounce
* Provides a debounce function used to debounce calls to a user-provided function.
* @template {function(?): void} T args
* @typedef {function(T, number, boolean): T} miscDebounce
*/

/**
* Provides a debounce service. That service is a function
* used to debounce calls to a user-provided function.
*
* @template {function(?): void} T args
* @param {angular.ITimeoutService} $timeout Angular timeout service.
* @return {import("ngeo/misc/debounce.js").miscDebounce} The debounce function.
* @return {import("ngeo/misc/debounce.js").miscDebounce<T>} The debounce function.
*
* @ngdoc service
* @ngname ngeoDebounce
Expand All @@ -26,18 +27,18 @@ const factory = function($timeout) {
return (
// FIXME: eslint can't detect that the function returns a function
/**
* @param {function(?)} func The function to debounce.
* @param {T} func The function to debounce.
* @param {number} wait The wait time in ms.
* @param {boolean} invokeApply Whether the call to `func` is wrapped
* into an `$apply` call.
* return {function()} The wrapper function.
* @return {T} The wrapper function.
*/
function(func, wait, invokeApply) {
/**
* @type {?angular.IPromise}
*/
let timeout = null;
return (
return /** @type {T} */(
function(...args) {
const context = this;
const later = function() {
Expand Down
4 changes: 2 additions & 2 deletions src/olcs/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const OlcsService = class {

/**
* @ngInject
* @param {!import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce ngeo debounce service.
* @param {!import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce ngeo debounce service.
* @param {!import("ngeo/statemanager/Location.js").StatemanagerLocation} ngeoLocation ngeo location service.
* @param {import("ngeo/statemanager/Service.js").StatemanagerService} ngeoStateManager The ngeo StateManager service.
*/
Expand All @@ -21,7 +21,7 @@ export const OlcsService = class {

/**
* @private
* @type {!import("ngeo/misc/debounce.js").miscDebounce}
* @type {!import("ngeo/misc/debounce.js").miscDebounce<function(): void>}
*/
this.ngeoDebounce_ = ngeoDebounce;

Expand Down
2 changes: 1 addition & 1 deletion src/profile/elevationComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const module = angular.module('ngeoProfile', [
* @htmlAttribute {?Array} ngeo-profile-pois The data for POIs.
* @htmlAttribute {*} ngeo-profile-highlight Any property on the scope which
* evaluated value may correspond to distance from origin.
* @param {import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce ngeo Debounce factory.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(import('ol/events/Event.js').default): void>} ngeoDebounce ngeo Debounce factory.
* @return {angular.IDirective} Directive Definition Object.
* @ngInject
* @ngdoc directive
Expand Down
3 changes: 2 additions & 1 deletion src/routing/NominatimInputComponent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import angular from 'angular';
import ngeoSearchSearchDirective from 'ngeo/search/searchDirective.js';
import ngeoRoutingNominatimService from 'ngeo/routing/NominatimService.js';
import olEventsEvent from 'ol/events/Event.js';


/**
Expand Down Expand Up @@ -98,7 +99,7 @@ function Controller($element, $injector, $scope, ngeoNominatimService) {
this.datasets = [/** @type {Twitter.Typeahead.Dataset} */({
name: 'nominatim',
display: 'name',
source: this.ngeoNominatimService.typeaheadSourceDebounced
source: ngeoNominatimService.typeaheadSourceDebounced,
})];

/**
Expand Down
7 changes: 3 additions & 4 deletions src/routing/NominatimService.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import ngeoMiscDebounce from 'ngeo/misc/debounce.js';
* OSM data by name and address.
* @param {angular.IHttpService} $http Angular http service.
* @param {angular.auto.IInjectorService} $injector Main injector.
* @param {import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce ngeo Debounce service.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(string, function(Array<Object>): void, function(Array<NominatimSearchResult>): void): void>} ngeoDebounce ngeo Debounce service.
* @constructor
* @ngdoc service
* @ngInject
Expand All @@ -40,7 +40,7 @@ export function NominatimService($http, $injector, ngeoDebounce) {
this.$http_ = $http;

/**
* @type {import("ngeo/misc/debounce.js").miscDebounce}
* @type {import("ngeo/misc/debounce.js").miscDebounce<function(string, function(Array<Object>): void, function(Array<NominatimSearchResult>): void): void>}
* @private
*/
this.ngeoDebounce_ = ngeoDebounce;
Expand Down Expand Up @@ -82,8 +82,7 @@ export function NominatimService($http, $injector, ngeoDebounce) {
this.typeaheadDebounceDelay_ = 500;

/**
* @export
* @type {Bloodhound | ((query: string, syncResults: (result: []) => void, asyncResults?: (result: []) => void) => void)}
* @type {function(string, function(Array<Object>): void, function(Array<NominatimSearchResult>): void): void}
*/
this.typeaheadSourceDebounced =
this.ngeoDebounce_(this.typeaheadSource_.bind(this), this.typeaheadDebounceDelay_, true);
Expand Down
8 changes: 2 additions & 6 deletions src/routing/RoutingComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function ngeoRoutingTemplateUrl($attrs, ngeoRoutingTemplateUrl) {
* @param {!import("ngeo/routing/RoutingService.js").RoutingService} ngeoRoutingService service for OSRM routing
* @param {!import("ngeo/routing/NominatimService.js").NominatimService} ngeoNominatimService service for Nominatim
* @param {!angular.IQService} $q Angular q service
* @param {import("ngeo/misc/debounce.js").miscDebounce} ngeoDebounce ngeo Debounce service.
* @param {import("ngeo/misc/debounce.js").miscDebounce<function(): void>} ngeoDebounce ngeo Debounce service.
* @constructor
* @private
* @ngInject
Expand Down Expand Up @@ -234,11 +234,7 @@ function Controller($injector, $scope, ngeoRoutingService, ngeoNominatimService,
* @export
* @type {function(): void}
*/
this.handleChange = /** @type {function(): void} */
(ngeoDebounce(
/** @type {function(?): void} */ (this.calculateRoute.bind(this)),
debounceDelay,
true));
this.handleChange = ngeoDebounce(this.calculateRoute.bind(this), debounceDelay, true);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/rule/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ngeoRuleRule, {RuleOperatorType} from 'ngeo/rule/Rule.js';
* @property {string} name (RuleOptions)
* @property {string} [operator] (RuleOptions)
* @property {Array.<string>} [operators] (RuleOptions)
* @property {string} [propertyName] (RuleOptions)
* @property {string} propertyName (RuleOptions)
* @property {string} [type] (RuleOptions)
* @property {number} [upperBoundary] (RuleOptions)
*/
Expand All @@ -36,9 +36,11 @@ export default class extends ngeoRuleRule {
* @param {!TextOptions} options Options.
*/
constructor(options) {
/** @type {import('ngeo/rule/Rule.js').RuleOptions} */
const rule_options = options;
options.operator = options.operator || RuleOperatorType.LIKE;
options.type = ngeoFormatAttributeType.TEXT;

super(options);
super(rule_options);
}
}

0 comments on commit 3aa8f10

Please sign in to comment.