diff --git a/src/render/glyph_manager.js b/src/render/glyph_manager.js index ad13298e4e4..c65c7490759 100644 --- a/src/render/glyph_manager.js +++ b/src/render/glyph_manager.js @@ -8,6 +8,7 @@ const {AlphaImage} = require('../util/image'); import type {StyleGlyph} from '../style/style_glyph'; import type {RequestTransformFunction} from '../ui/map'; +import type {Callback} from '../types/callback'; type Entry = { // null means we've requested the range, but the glyph wasn't included in the result. diff --git a/src/render/image_manager.js b/src/render/image_manager.js index 252b5632251..c5fbd954ca8 100644 --- a/src/render/image_manager.js +++ b/src/render/image_manager.js @@ -9,6 +9,7 @@ const assert = require('assert'); import type {StyleImage} from '../style/style_image'; import type {ImagePosition} from './image_atlas'; import type {Bin} from '@mapbox/shelf-pack'; +import type {Callback} from '../types/callback'; type Pattern = { bin: Bin, diff --git a/src/source/geojson_source.js b/src/source/geojson_source.js index 8497ac7ed21..a20c993cf47 100644 --- a/src/source/geojson_source.js +++ b/src/source/geojson_source.js @@ -11,6 +11,7 @@ import type {Source} from './source'; import type Map from '../ui/map'; import type Dispatcher from '../util/dispatcher'; import type Tile from './tile'; +import type {Callback} from '../types/callback'; /** * A source containing GeoJSON. diff --git a/src/source/geojson_worker_source.js b/src/source/geojson_worker_source.js index 90486dc1763..0328fad60a1 100644 --- a/src/source/geojson_worker_source.js +++ b/src/source/geojson_worker_source.js @@ -19,6 +19,7 @@ import type StyleLayerIndex from '../style/style_layer_index'; import type {LoadVectorDataCallback} from './vector_tile_worker_source'; import type {RequestParameters} from '../util/ajax'; +import type { Callback } from '../types/callback'; export type GeoJSON = Object; diff --git a/src/source/image_source.js b/src/source/image_source.js index a7c9e8a41fd..1a7a4a3b38e 100644 --- a/src/source/image_source.js +++ b/src/source/image_source.js @@ -19,6 +19,7 @@ import type Map from '../ui/map'; import type Dispatcher from '../util/dispatcher'; import type Tile from './tile'; import type Coordinate from '../geo/coordinate'; +import type {Callback} from '../types/callback'; export type ImageTextureSource = ImageData | diff --git a/src/source/load_tilejson.js b/src/source/load_tilejson.js index e49e228e4d3..5b9f4d9bec6 100644 --- a/src/source/load_tilejson.js +++ b/src/source/load_tilejson.js @@ -6,6 +6,7 @@ const browser = require('../util/browser'); const normalizeURL = require('../util/mapbox').normalizeSourceURL; import type {RequestTransformFunction} from '../ui/map'; +import type {Callback} from '../types/callback'; module.exports = function(options: any, requestTransformFn: RequestTransformFunction, callback: Callback) { const loaded = function(err, tileJSON: any) { diff --git a/src/source/raster_tile_source.js b/src/source/raster_tile_source.js index ef93dbccad9..431367380e2 100644 --- a/src/source/raster_tile_source.js +++ b/src/source/raster_tile_source.js @@ -13,6 +13,7 @@ import type TileCoord from './tile_coord'; import type Map from '../ui/map'; import type Dispatcher from '../util/dispatcher'; import type Tile from './tile'; +import type {Callback} from '../types/callback'; class RasterTileSource extends Evented implements Source { type: 'raster'; diff --git a/src/source/source.js b/src/source/source.js index be8d46330bf..28669696936 100644 --- a/src/source/source.js +++ b/src/source/source.js @@ -7,6 +7,7 @@ import type Evented from '../util/evented'; import type Map from '../ui/map'; import type Tile from './tile'; import type TileCoord from './tile_coord'; +import type {Callback} from '../types/callback'; /** * The `Source` interface must be implemented by each source type, including "core" types (`vector`, `raster`, diff --git a/src/source/source_cache.js b/src/source/source_cache.js index 729d35345b4..1e55d4d8cb3 100644 --- a/src/source/source_cache.js +++ b/src/source/source_cache.js @@ -17,6 +17,7 @@ import type Dispatcher from '../util/dispatcher'; import type Transform from '../geo/transform'; import type {TileState} from './tile'; import type CollisionIndex from '../symbol/collision_index'; +import type {Callback} from '../types/callback'; /** * `SourceCache` is responsible for diff --git a/src/source/vector_tile_source.js b/src/source/vector_tile_source.js index 1bc9d148bb4..5568043c350 100644 --- a/src/source/vector_tile_source.js +++ b/src/source/vector_tile_source.js @@ -13,6 +13,7 @@ import type TileCoord from './tile_coord'; import type Map from '../ui/map'; import type Dispatcher from '../util/dispatcher'; import type Tile from './tile'; +import type {Callback} from '../types/callback'; class VectorTileSource extends Evented implements Source { type: 'vector'; diff --git a/src/source/vector_tile_worker_source.js b/src/source/vector_tile_worker_source.js index 6a07d0a9125..bc21ccdd15b 100644 --- a/src/source/vector_tile_worker_source.js +++ b/src/source/vector_tile_worker_source.js @@ -15,6 +15,7 @@ import type { import type Actor from '../util/actor'; import type StyleLayerIndex from '../style/style_layer_index'; +import type {Callback} from '../types/callback'; export type LoadVectorTileResult = { vectorTile: VectorTile; diff --git a/src/source/worker.js b/src/source/worker.js index a5ed9400f9b..aff8c64e8be 100644 --- a/src/source/worker.js +++ b/src/source/worker.js @@ -17,6 +17,7 @@ import type { } from '../source/worker_source'; import type {WorkerGlobalScopeInterface} from '../util/web_worker'; +import type {Callback} from '../types/callback'; /** * @private diff --git a/src/style/load_glyph_range.js b/src/style/load_glyph_range.js index e9eb5169f16..6dcef00459c 100644 --- a/src/style/load_glyph_range.js +++ b/src/style/load_glyph_range.js @@ -6,6 +6,7 @@ const parseGlyphPBF = require('./parse_glyph_pbf'); import type {StyleGlyph} from './style_glyph'; import type {RequestTransformFunction} from '../ui/map'; +import type {Callback} from '../types/callback'; module.exports = function (fontstack: string, range: number, diff --git a/src/style/load_sprite.js b/src/style/load_sprite.js index 473d836aee6..6f6bdfee91b 100644 --- a/src/style/load_sprite.js +++ b/src/style/load_sprite.js @@ -7,6 +7,7 @@ const {RGBAImage} = require('../util/image'); import type {StyleImage} from './style_image'; import type {RequestTransformFunction} from '../ui/map'; +import type {Callback} from '../types/callback'; module.exports = function(baseURL: string, transformRequestCallback: RequestTransformFunction, diff --git a/src/style/style.js b/src/style/style.js index c6aa53f66e4..6ee38275f6e 100644 --- a/src/style/style.js +++ b/src/style/style.js @@ -33,6 +33,7 @@ import type {Source} from '../source/source'; import type {StyleImage} from './style_image'; import type {StyleGlyph} from './style_glyph'; import type CollisionIndex from '../symbol/collision_index'; +import type {Callback} from '../types/callback'; const supportedDiffOperations = util.pick(diff.operations, [ 'addLayer', diff --git a/flow-typed/callback.js b/src/types/callback.js similarity index 87% rename from flow-typed/callback.js rename to src/types/callback.js index de55bcd014c..1c5416c00fc 100644 --- a/flow-typed/callback.js +++ b/src/types/callback.js @@ -1,3 +1,4 @@ +// @flow // Flow can't perfectly type Node-style callbacks yet; it does not have a way to // express that if the first parameter is null, the second is not, so for the time @@ -13,5 +14,4 @@ // }); // // See https://github.com/facebook/flow/issues/2123 for more. - -declare type Callback = (error: ?Error, result: ?T) => void; +export type Callback = (error: ?Error, result: ?T) => void; diff --git a/src/util/ajax.js b/src/util/ajax.js index 5d97c29936e..94dec7bdf01 100644 --- a/src/util/ajax.js +++ b/src/util/ajax.js @@ -2,6 +2,8 @@ const window = require('./window'); +import type { Callback } from '../types/callback'; + /** * The type of a resource. * @private diff --git a/src/util/util.js b/src/util/util.js index 540e65f43d2..2236d92255f 100644 --- a/src/util/util.js +++ b/src/util/util.js @@ -4,6 +4,8 @@ const UnitBezier = require('@mapbox/unitbezier'); const Coordinate = require('../geo/coordinate'); const Point = require('@mapbox/point-geometry'); +import type {Callback} from '../types/callback'; + /** * @module util * @private