Skip to content

Commit

Permalink
fix: Corrections to type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-suhas committed Jun 3, 2018
1 parent 580fda7 commit 3792268
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MatrixStatsAggregation extends Aggregation {
* const agg = esb.matrixStatsAggregation('matrixstats')
* .fields(['poverty', 'income']);
*
* @param {Array} fields Array of fields
* @param {Array<string>} fields Array of fields
* @returns {MatrixStatsAggregation} returns `this` so that calls can be chained
*/
fields(fields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class PercentileRanksAggregation extends MetricsAggregationBase {
/**
* Specifies the values to compute percentiles from.
*
* @param {Array} values Values to compute percentiles from.
* @param {Array<number>} values Values to compute percentiles from.
* @returns {PercentileRanksAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `values` is not an instance of Array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PercentilesAggregation extends MetricsAggregationBase {
* 'load_time'
* ).percents([95, 99, 99.9]);
*
* @param {Array} percents Parameter to specify particular percentiles to calculate
* @param {Array<number>} percents Parameter to specify particular percentiles to calculate
* @returns {PercentilesAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `percents` is not an instance of Array
*/
Expand Down
4 changes: 2 additions & 2 deletions src/aggregations/metrics-aggregations/top-hits-aggregation.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class TopHitsAggregation extends MetricsAggregationBase {
* The sort is defined on a per field level, with special field name for _score to
* sort by score, and _doc to sort by index order.
*
* @param {Array} sorts Arry of sort How the top matching hits should be sorted.
* @param {Array<Sort>} sorts Arry of sort How the top matching hits should be sorted.
* @returns {TopHitsAggregation} returns `this` so that calls can be chained.
* @throws {TypeError} If any item in parameter `sorts` is not an instance of `Sort`.
*/
Expand Down Expand Up @@ -264,7 +264,7 @@ class TopHitsAggregation extends MetricsAggregationBase {
* Allows to return the doc value representation of a field for each hit.
* Doc value fields can work on fields that are not stored.
*
* @param {Array} fields
* @param {Array<string>} fields
* @returns {TopHitsAggregation} returns `this` so that calls can be chained
*/
docvalueFields(fields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PercentilesBucketAggregation extends PipelineAggregationBase {
/**
* Sets the list of percentiles to calculate
*
* @param {Array} percents The list of percentiles to calculate
* @param {Array<number>} percents The list of percentiles to calculate
* @returns {PercentilesBucketAggregation} returns `this` so that calls can be chained
*/
percents(percents) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/aggregation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Aggregation {
* Sets multiple nested aggregation items.
* This method accepts an array to set multiple nested aggregations in one call.
*
* @param {Array} aggs Array of valid {@link Aggregation} items
* @param {Array<Aggregation>} aggs Array of valid {@link Aggregation} items
* @returns {Aggregation} returns `this` so that calls can be chained.
* @throws {TypeError} If `aggs` is not an instance of `Array`
* @throws {TypeError} If `aggs` contains instances not of type `Aggregation`
Expand All @@ -97,7 +97,7 @@ class Aggregation {
* Sets multiple nested aggregation items.
* Alias for method `aggregations`
*
* @param {Array} aggs Array of valid {@link Aggregation} items
* @param {Array<Aggregation>} aggs Array of valid {@link Aggregation} items
* @returns {Aggregation} returns `this` so that calls can be chained.
* @throws {TypeError} If `aggs` is not an instance of `Array`
* @throws {TypeError} If `aggs` contains instances not of type `Aggregation`
Expand Down
2 changes: 1 addition & 1 deletion src/core/geo-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class GeoPoint {
* Sets the Geo Point value expressed as an array
* with the format: `[ lon, lat ]`.
*
* @param {Array} point Array in format `[ lon, lat ]`(`GeoJson` standard)
* @param {Array<number>} point Array in format `[ lon, lat ]`(`GeoJson` standard)
* @returns {GeoPoint} returns `this` so that calls can be chained
* @throws {TypeError} If `point` is not an instance of Array
*/
Expand Down
2 changes: 1 addition & 1 deletion src/core/geo-shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GeoShape {
* .type('point')
* .coordinates([-77.03653, 38.897676])
*
* @param {Array} coords
* @param {Array<number>} coords
* @returns {GeoShape} returns `this` so that calls can be chained.
*/
coordinates(coords) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Highlight {
* Allows you to set a field that will be highlighted. The field is
* added to the current list of fields.
*
* @param {Array} field A field name.
* @param {string} field A field name.
* @returns {Highlight} returns `this` so that calls can be chained
*/
field(field) {
Expand All @@ -123,7 +123,7 @@ class Highlight {
* Allows you to set the fields that will be highlighted. All fields are
* added to the current list of fields.
*
* @param {Array} fields Array of field names.
* @param {Array<string>} fields Array of field names.
* @returns {Highlight} returns `this` so that calls can be chained
* @throws {TypeError} If `fields` is not an instance of Array
*/
Expand Down Expand Up @@ -333,7 +333,7 @@ class Highlight {
* }
* }
*
* @param {Array} fields
* @param {Array<string>} fields
* @param {string} field Field name
* @returns {Highlight} returns `this` so that calls can be chained
* @throws {Error} field parameter should be valid field name
Expand Down
2 changes: 1 addition & 1 deletion src/core/inner-hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class InnerHits {
* Allows to return the doc value representation of a field for each hit.
* Doc value fields can work on fields that are not stored.
*
* @param {Array} fields
* @param {Array<string>} fields
* @returns {InnerHits} returns `this` so that calls can be chained
*/
docvalueFields(fields) {
Expand Down
8 changes: 4 additions & 4 deletions src/core/request-body-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class RequestBodySearch {
* Sets multiple nested aggregation items.
* Alias for method `aggregations`
*
* @param {Array} aggs Array of valid {@link Aggregation} items
* @param {Array<Aggregation>} aggs Array of valid {@link Aggregation} items
* @returns {Aggregation} returns `this` so that calls can be chained.
* @throws {TypeError} If `aggs` is not an instance of `Array`
* @throws {TypeError} If `aggs` contains instances not of type `Aggregation`
Expand All @@ -130,7 +130,7 @@ class RequestBodySearch {
* Sets multiple nested aggregation items.
* This method accepts an array to set multiple nested aggregations in one call.
*
* @param {Array} aggs Array of valid {@link Aggregation} items
* @param {Array<Aggregation>} aggs Array of valid {@link Aggregation} items
* @returns {Aggregation} returns `this` so that calls can be chained.
* @throws {TypeError} If `aggs` is not an instance of `Array`
* @throws {TypeError} If `aggs` contains instances not of type `Aggregation`
Expand Down Expand Up @@ -472,7 +472,7 @@ class RequestBodySearch {
* .query(esb.matchAllQuery())
* .docvalueFields(['test1', 'test2']);
*
* @param {Array} fields
* @param {Array<string>} fields
* @returns {RequestBodySearch} returns `this` so that calls can be chained
*/
docvalueFields(fields) {
Expand Down Expand Up @@ -752,7 +752,7 @@ class RequestBodySearch {
* .searchAfter(1463538857, 'tweet#654323')
* .sorts([esb.sort('date', 'asc'), esb.sort('_uid', 'desc')]);
*
* @param {Array} values The `sort values` of the last document to retrieve
* @param {Array<*>} values The `sort values` of the last document to retrieve
* the next page of results
* @returns {RequestBodySearch} returns `this` so that calls can be chained.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/core/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class Script {
this._isTypeSet = false;
this._body = {};

// NOTE: Script syntax changed in elasticsearch 5.6 to use `id`/`source`
// instead of `inline`/`source`/`file`. This needs to be handled
// somehow.
if (!isNil(type) && !isNil(source)) {
const typeLower = type.toLowerCase();

Expand Down
Loading

0 comments on commit 3792268

Please sign in to comment.