Skip to content

Commit

Permalink
Remove Callback type as a global.
Browse files Browse the repository at this point in the history
  • Loading branch information
vicapow authored and jfirebaugh committed Nov 13, 2017
1 parent 5bebe1c commit 7386da6
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/render/glyph_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/render/image_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/source/geojson_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/source/geojson_worker_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/source/image_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions src/source/load_tilejson.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<TileJSON>) {
const loaded = function(err, tileJSON: any) {
Expand Down
1 change: 1 addition & 0 deletions src/source/raster_tile_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/source/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
1 change: 1 addition & 0 deletions src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/source/vector_tile_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/source/vector_tile_worker_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/source/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
} from '../source/worker_source';

import type {WorkerGlobalScopeInterface} from '../util/web_worker';
import type {Callback} from '../types/callback';

/**
* @private
Expand Down
1 change: 1 addition & 0 deletions src/style/load_glyph_range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/style/load_sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions flow-typed/callback.js → src/types/callback.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,5 +14,4 @@
// });
//
// See https://github.com/facebook/flow/issues/2123 for more.

declare type Callback<T> = (error: ?Error, result: ?T) => void;
export type Callback<T> = (error: ?Error, result: ?T) => void;
2 changes: 2 additions & 0 deletions src/util/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const window = require('./window');

import type { Callback } from '../types/callback';

/**
* The type of a resource.
* @private
Expand Down
2 changes: 2 additions & 0 deletions src/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7386da6

Please sign in to comment.