Skip to content

Commit

Permalink
Final commit - remove the rest of undefined | null
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM committed Sep 11, 2021
1 parent 60ae2d9 commit ac88200
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/geo/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Transform {
_posMatrixCache: {[_: string]: mat4};
_alignedPosMatrixCache: {[_: string]: mat4};

constructor(minZoom: number | undefined | null, maxZoom: number | undefined | null, minPitch: number | undefined | null, maxPitch: number | undefined | null, renderWorldCopies: boolean) {
constructor(minZoom: number, maxZoom: number, minPitch: number, maxPitch: number, renderWorldCopies: boolean) {
this.tileSize = 512; // constant
this.maxValidLatitude = 85.051129; // constant

Expand Down Expand Up @@ -126,7 +126,7 @@ class Transform {
}

get renderWorldCopies(): boolean { return this._renderWorldCopies; }
set renderWorldCopies(renderWorldCopies: boolean | undefined | null) {
set renderWorldCopies(renderWorldCopies: boolean) {
if (renderWorldCopies === undefined) {
renderWorldCopies = true;
} else if (renderWorldCopies === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/image_atlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default class ImageAtlas {
}
}

patchUpdatedImage(position: ImagePosition | undefined | null, image: StyleImage | undefined | null, texture: Texture) {
patchUpdatedImage(position: ImagePosition, image: StyleImage, texture: Texture) {
if (!position || !image) return;

if (position.version === image.version) return;
Expand Down
4 changes: 2 additions & 2 deletions src/render/image_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class ImageManager extends Evented {
return valid;
}

_validateStretch(stretch: Array<[number, number]> | undefined | null | void, size: number) {
_validateStretch(stretch: Array<[number, number]>, size: number) {
if (!stretch) return true;
let last = 0;
for (const part of stretch) {
Expand All @@ -120,7 +120,7 @@ class ImageManager extends Evented {
return true;
}

_validateContent(content: [number, number, number, number] | undefined | null | void, image: StyleImage) {
_validateContent(content: [number, number, number, number], image: StyleImage) {
if (!content) return true;
if (content.length !== 4) return false;
if (content[0] < 0 || image.data.width < content[0]) return false;
Expand Down
2 changes: 1 addition & 1 deletion src/source/load_tilejson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {TileJSON} from '../types/tilejson';
import type {Cancelable} from '../types/cancelable';

export default function(options: any, requestManager: RequestManager, callback: Callback<TileJSON>): Cancelable {
const loaded = function(err: Error | undefined | null, tileJSON: any) {
const loaded = function(err: Error, tileJSON: any) {
if (err) {
return callback(err);
} else if (tileJSON) {
Expand Down
2 changes: 1 addition & 1 deletion src/source/query_features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getPixelPosMatrix(transform, tileID) {
return mat4.multiply(t, t, transform.calculatePosMatrix(tileID.toUnwrapped()));
}

function queryIncludes3DLayer(layers: Array<string> | undefined | null, styleLayers: {[_: string]: StyleLayer}, sourceID: string) {
function queryIncludes3DLayer(layers: Array<string>, styleLayers: {[_: string]: StyleLayer}, sourceID: string) {
if (layers) {
for (const layerID of layers) {
const layer = styleLayers[layerID];
Expand Down
4 changes: 2 additions & 2 deletions src/source/rtl_text_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let _completionCallback = null;
let pluginStatus = status.unavailable;
let pluginURL = null;

export const triggerPluginCompletionEvent = function(error: Error | string | undefined | null) {
export const triggerPluginCompletionEvent = function(error: Error | string) {
// NetworkError's are not correctly reflected by the plugin status which prevents reloading plugin
if (error && typeof error === 'string' && error.indexOf('NetworkError') > -1) {
pluginStatus = status.error;
Expand Down Expand Up @@ -59,7 +59,7 @@ export const clearRTLTextPlugin = function() {
pluginURL = null;
};

export const setRTLTextPlugin = function(url: string, callback: ErrorCallback | undefined | null, deferred: boolean = false) {
export const setRTLTextPlugin = function(url: string, callback: ErrorCallback, deferred: boolean = false) {
if (pluginStatus === status.deferred || pluginStatus === status.loading || pluginStatus === status.loaded) {
throw new Error('setRTLTextPlugin cannot be called multiple times.');
}
Expand Down
4 changes: 2 additions & 2 deletions src/source/source_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ class SourceCache extends Evented {
* Set the value of a particular state for a feature
* @private
*/
setFeatureState(sourceLayer: string | undefined | null, featureId: number | string, state: any) {
setFeatureState(sourceLayer: string, featureId: number | string, state: any) {
sourceLayer = sourceLayer || '_geojsonTileLayer';
this._state.updateState(sourceLayer, featureId, state);
}
Expand All @@ -907,7 +907,7 @@ class SourceCache extends Evented {
* Get the entire state object for a feature
* @private
*/
getFeatureState(sourceLayer: string | undefined | null, featureId: number | string) {
getFeatureState(sourceLayer: string, featureId: number | string) {
sourceLayer = sourceLayer || '_geojsonTileLayer';
return this._state.getState(sourceLayer, featureId);
}
Expand Down
4 changes: 2 additions & 2 deletions src/source/tile_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ class TileCache {
*/
remove(tileID: OverscaledTileID, value?: {
value: Tile;
timeout: ReturnType<typeof setTimeout> | undefined | null;
} | null) {
timeout: ReturnType<typeof setTimeout>;
}) {
if (!this.has(tileID)) { return this; }
const key = tileID.wrapped().key;

Expand Down
4 changes: 2 additions & 2 deletions src/style-spec/error/validation_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export default class ValidationError {
identifier: string;
line: number;

constructor(key: string | undefined | null, value: {
constructor(key: string, value: {
__line__: number;
} | undefined | null, message: string, identifier?: string | null) {
}, message: string, identifier?: string | null) {
this.message = (key ? `${key}: ` : '') + message;
if (identifier) this.identifier = identifier;

Expand Down
12 changes: 6 additions & 6 deletions src/style/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class TransitioningPropertyValue<T, R> {

constructor(property: Property<T, R>,
value: PropertyValue<T, R>,
prior: TransitioningPropertyValue<T, R> | undefined | null,
prior: TransitioningPropertyValue<T, R>,
transition: TransitionSpecification,
now: TimePoint) {
this.property = property;
Expand Down Expand Up @@ -586,7 +586,7 @@ export class DataDrivenProperty<T> implements Property<T, PossiblyEvaluatedPrope
export class CrossFadedDataDrivenProperty<T> extends DataDrivenProperty<CrossFaded<T>> {

possiblyEvaluate(
value: PropertyValue<CrossFaded<T> | undefined | null, PossiblyEvaluatedPropertyValue<CrossFaded<T> | undefined | null>>,
value: PropertyValue<CrossFaded<T>, PossiblyEvaluatedPropertyValue<CrossFaded<T>>>,
parameters: EvaluationParameters,
canonical?: CanonicalTileID,
availableImages?: Array<string>
Expand All @@ -613,7 +613,7 @@ export class CrossFadedDataDrivenProperty<T> extends DataDrivenProperty<CrossFad
}

evaluate(
value: PossiblyEvaluatedValue<CrossFaded<T> | undefined | null>,
value: PossiblyEvaluatedValue<CrossFaded<T>>,
globals: EvaluationParameters,
feature: Feature,
featureState: FeatureState,
Expand All @@ -639,7 +639,7 @@ export class CrossFadedDataDrivenProperty<T> extends DataDrivenProperty<CrossFad
return z > parameters.zoomHistory.lastIntegerZoom ? {from: min, to: mid} : {from: max, to: mid};
}

interpolate(a: PossiblyEvaluatedPropertyValue<CrossFaded<T> | undefined | null>): PossiblyEvaluatedPropertyValue<CrossFaded<T> | undefined | null> {
interpolate(a: PossiblyEvaluatedPropertyValue<CrossFaded<T>>): PossiblyEvaluatedPropertyValue<CrossFaded<T>> {
return a;
}
}
Expand All @@ -657,11 +657,11 @@ export class CrossFadedProperty<T> implements Property<T, CrossFaded<T>> {
}

possiblyEvaluate(
value: PropertyValue<T, CrossFaded<T> | undefined | null>,
value: PropertyValue<T, CrossFaded<T>>,
parameters: EvaluationParameters,
canonical?: CanonicalTileID,
availableImages?: Array<string>
): CrossFaded<T> | undefined | null {
): CrossFaded<T> {
if (value.value === undefined) {
return undefined;
} else if (value.expression.kind === 'constant') {
Expand Down
6 changes: 3 additions & 3 deletions src/style/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,8 @@ class Style extends Evented {
querySourceFeatures(
sourceID: string,
params?: {
sourceLayer: string | undefined | null;
filter: Array<any> | undefined | null;
sourceLayer: string;
filter: Array<any>;
validate?: boolean;
} | null
) {
Expand Down Expand Up @@ -1384,7 +1384,7 @@ class Style extends Evented {
getGlyphs(
mapId: string,
params: {stacks: {[_: string]: Array<number>}},
callback: Callback<{[_: string]: {[_: number]: StyleGlyph | undefined | null}}>
callback: Callback<{[_: string]: {[_: number]: StyleGlyph}}>
) {
this.glyphManager.getGlyphs(params.stacks, callback);
}
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/collision_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ class CollisionIndex {
fontSize: number,
posMatrix: mat4,
labelPlaneMatrix: mat4,
labelToScreenMatrix: mat4 | undefined | null,
labelToScreenMatrix: mat4,
showCollisionCircles: boolean,
pitchWithMap: boolean,
collisionGroupPredicate: any | undefined | null,
collisionGroupPredicate: any,
circlePixelDiameter: number,
textPixelPadding: number
): {
Expand Down
10 changes: 5 additions & 5 deletions src/symbol/get_anchors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function getLineLength(line: Array<Point>): number {
}

function getAngleWindowSize(
shapedText: Shaping | undefined | null,
shapedText: Shaping,
glyphSize: number,
boxScale: number
): number {
Expand All @@ -34,8 +34,8 @@ function getShapedLabelLength(shapedText?: Shaping | null, shapedIcon?: Position

function getCenterAnchor(line: Array<Point>,
maxAngle: number,
shapedText: Shaping | undefined | null,
shapedIcon: PositionedIcon | undefined | null,
shapedText: Shaping,
shapedIcon: PositionedIcon,
glyphSize: number,
boxScale: number) {
const angleWindowSize = getAngleWindowSize(shapedText, glyphSize, boxScale);
Expand Down Expand Up @@ -73,8 +73,8 @@ function getCenterAnchor(line: Array<Point>,
function getAnchors(line: Array<Point>,
spacing: number,
maxAngle: number,
shapedText: Shaping | undefined | null,
shapedIcon: PositionedIcon | undefined | null,
shapedText: Shaping,
shapedIcon: PositionedIcon,
glyphSize: number,
boxScale: number,
overscaling: number,
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/placement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {TextAnchor} from './symbol_layout';
class OpacityState {
opacity: number;
placed: boolean;
constructor(prevState: OpacityState | undefined | null, increment: number, placed: boolean, skipFade?: boolean | null) {
constructor(prevState: OpacityState, increment: number, placed: boolean, skipFade?: boolean | null) {
if (prevState) {
this.opacity = Math.max(0, Math.min(1, prevState.opacity + (prevState.placed ? increment : -increment)));
} else {
Expand All @@ -38,7 +38,7 @@ class OpacityState {
class JointOpacityState {
text: OpacityState;
icon: OpacityState;
constructor(prevState: JointOpacityState | undefined | null, increment: number, placedText: boolean, placedIcon: boolean, skipFade?: boolean | null) {
constructor(prevState: JointOpacityState, increment: number, placedText: boolean, placedIcon: boolean, skipFade?: boolean | null) {
this.text = new OpacityState(prevState ? prevState.text : null, increment, placedText, skipFade);
this.icon = new OpacityState(prevState ? prevState.icon : null, increment, placedIcon, skipFade);
}
Expand Down
2 changes: 1 addition & 1 deletion src/symbol/symbol_layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ function addSymbol(bucket: SymbolBucket,
// All measurements are in glyph metrics and later converted into pixels using proper font size "layoutTextSize"
let collisionCircleDiameter = -1;

const getCollisionCircleHeight = (feature: CollisionFeature | undefined | null, prevHeight: number): number => {
const getCollisionCircleHeight = (feature: CollisionFeature, prevHeight: number): number => {
if (feature && feature.circleDiameter)
return Math.max(feature.circleDiameter, prevHeight);
return prevHeight;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ abstract class Camera extends Evented {
return this;
}

_prepareEase(eventData: any | undefined | null, noMoveStart: boolean, currently: any = {}) {
_prepareEase(eventData: any, noMoveStart: boolean, currently: any = {}) {
this._moving = true;

if (!noMoveStart && !currently.moving) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1306,8 +1306,8 @@ class Map extends Camera {
*
*/
querySourceFeatures(sourceId: string, parameters?: {
sourceLayer: string | undefined | null;
filter: Array<any> | undefined | null;
sourceLayer: string;
filter: Array<any>;
validate?: boolean;
} | null) {
return this.style.querySourceFeatures(sourceId, parameters);
Expand Down
4 changes: 2 additions & 2 deletions src/util/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Point from './point';
import assert from 'assert';

interface DOMInterface {
create(tagName: string, className?: string | undefined | null, container?: HTMLElement): HTMLElement;
create(tagName: string, className?: string, container?: HTMLElement): HTMLElement;
createNS(namespaceURI: string, tagName: string);
disableDrag();
enableDrag();
Expand All @@ -26,7 +26,7 @@ interface DOMInterface {
const DOM = {} as DOMInterface;
export default DOM;

DOM.create = function (tagName: string, className: string | undefined | null, container?: HTMLElement) {
DOM.create = function (tagName: string, className: string, container?: HTMLElement) {
const el = window.document.createElement(tagName);
if (className !== undefined) el.className = className;
if (container) container.appendChild(el);
Expand Down
2 changes: 1 addition & 1 deletion src/util/smart_wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type Transform from '../geo/transform';
*
* @private
*/
export default function(lngLat: LngLat, priorPos: Point | undefined | null, transform: Transform): LngLat {
export default function(lngLat: LngLat, priorPos: Point, transform: Transform): LngLat {
lngLat = new LngLat(lngLat.lng, lngLat.lat);

// First, try shifting one world in either direction, and see if either is closer to the
Expand Down

0 comments on commit ac88200

Please sign in to comment.