Skip to content

Commit

Permalink
Upgrade Flow to v0.85 and remove flow-coverage-report (mapbox#7565)
Browse files Browse the repository at this point in the history
* upgrade flow to v0.85

* fix lint

* remove flow-coverage-report

It was broken anyway, upgrading doesn't help, and we haven't really used it.
  • Loading branch information
mourner authored Nov 7, 2018
1 parent 081863d commit 7b4be8d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
.*/_site/.*

[version]
0.77.0
0.85.0
2 changes: 1 addition & 1 deletion bench/benchmarks/worker_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class WorkerTransfer extends Benchmark {
});
}

sendPayload(obj: any) {
sendPayload(obj: any): Promise<void> {
return new Promise((resolve) => {
this.worker.onmessage = () => resolve();
this.worker.postMessage(obj);
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.11.1",
"execcommand-copy": "^1.1.0",
"flow-bin": "^0.77.0",
"flow-coverage-report": "^0.3.0",
"flow-bin": "^0.85.0",
"github-slugger": "^1.1.1",
"gl": "^4.1.1",
"glob": "^7.0.3",
Expand Down Expand Up @@ -140,7 +139,6 @@
"test-query": "node test/query.test.js",
"test-expressions": "build/run-node test/expression.test.js",
"test-flow": "build/run-node build/generate-flow-typed-style-spec && flow .",
"test-flow-cov": "flow-coverage-report -i 'src/**/*.js' -t html",
"test-cov": "nyc --require=@mapbox/flow-remove-types/register --reporter=text-summary --reporter=lcov --cache run-s test-unit test-expressions test-query test-render",
"prepublishOnly": "run-s build-flow-types build-dev build-prod-min build-prod build-css build-style-spec test-build",
"codegen": "build/run-node build/generate-style-code.js && build/run-node build/generate-struct-arrays.js"
Expand Down
6 changes: 4 additions & 2 deletions src/geo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import Point from '@mapbox/point-geometry';
import { wrap, clamp } from '../util/util';
import {number as interpolate} from '../style-spec/util/interpolate';
import tileCover from '../util/tile_cover';
import { CanonicalTileID, UnwrappedTileID } from '../source/tile_id';
import { UnwrappedTileID } from '../source/tile_id';
import EXTENT from '../data/extent';
import { vec4, mat4, mat2 } from 'gl-matrix';

import type { OverscaledTileID, CanonicalTileID } from '../source/tile_id';

/**
* A single transform, generally used for a single tile to be
* scaled, rotated, and zoomed.
Expand Down Expand Up @@ -244,7 +246,7 @@ class Transform {
reparseOverscaled?: boolean,
renderWorldCopies?: boolean
}
) {
): Array<OverscaledTileID> {
let z = this.coveringZoomLevel(options);
const actualZ = z;

Expand Down
12 changes: 6 additions & 6 deletions src/style-spec/expression/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import RuntimeError from './runtime_error';
import { success, error } from '../util/result';
import { supportsPropertyExpression, supportsZoomExpression, supportsInterpolation } from '../util/properties';

import type {Type} from './types';
import type {Type, EvaluationKind} from './types';
import type {Value} from './values';
import type {Expression} from './expression';
import type {StylePropertySpecification} from '../style-spec';
Expand Down Expand Up @@ -120,15 +120,15 @@ export function createExpression(expression: mixed, propertySpec: StylePropertyS
return success(new StyleExpression(parsed, propertySpec));
}

export class ZoomConstantExpression<Kind> {
export class ZoomConstantExpression<Kind: EvaluationKind> {
kind: Kind;
isStateDependent: boolean;
_styleExpression: StyleExpression;

constructor(kind: Kind, expression: StyleExpression) {
this.kind = kind;
this._styleExpression = expression;
this.isStateDependent = kind !== 'constant' && !isConstant.isStateConstant(expression.expression);
this.isStateDependent = kind !== ('constant': EvaluationKind) && !isConstant.isStateConstant(expression.expression);
}

evaluateWithoutErrorHandling(globals: GlobalProperties, feature?: Feature, featureState?: FeatureState): any {
Expand All @@ -140,7 +140,7 @@ export class ZoomConstantExpression<Kind> {
}
}

export class ZoomDependentExpression<Kind> {
export class ZoomDependentExpression<Kind: EvaluationKind> {
kind: Kind;
zoomStops: Array<number>;
isStateDependent: boolean;
Expand All @@ -152,7 +152,7 @@ export class ZoomDependentExpression<Kind> {
this.kind = kind;
this.zoomStops = zoomCurve.labels;
this._styleExpression = expression;
this.isStateDependent = kind !== 'camera' && !isConstant.isStateConstant(expression.expression);
this.isStateDependent = kind !== ('camera': EvaluationKind) && !isConstant.isStateConstant(expression.expression);
if (zoomCurve instanceof Interpolate) {
this._interpolationType = zoomCurve.interpolation;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ export class StylePropertyFunction<T> {
_parameters: PropertyValueSpecification<T>;
_specification: StylePropertySpecification;

kind: 'constant' | 'source' | 'camera' | 'composite';
kind: EvaluationKind;
evaluate: (globals: GlobalProperties, feature?: Feature) => any;
interpolationFactor: ?(input: number, lower: number, upper: number) => number;
zoomStops: ?Array<number>;
Expand Down
2 changes: 2 additions & 0 deletions src/style-spec/expression/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export type ErrorTypeT = { kind: 'error' };
export type CollatorTypeT = { kind: 'collator' };
export type FormattedTypeT = { kind: 'formatted' };

export type EvaluationKind = 'constant' | 'source' | 'camera' | 'composite';

export type Type =
NullTypeT |
NumberTypeT |
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/validate/validate_expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createExpression, createPropertyExpression } from '../expression';
import { deepUnbundle } from '../util/unbundle_jsonlint';
import { isStateConstant } from '../expression/is_constant';

export default function validateExpression(options: any) {
export default function validateExpression(options: any): Array<ValidationError> {
const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);
if (expression.result === 'error') {
return expression.value.map((error) => {
Expand Down
4 changes: 2 additions & 2 deletions src/symbol/placement.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export class Placement {
this.placements = {};
this.opacities = {};
this.stale = false;
this.commitTime = 0;
this.fadeDuration = fadeDuration;
this.retainedQueryData = {};
this.collisionGroups = new CollisionGroups(crossSourceCollisions);
Expand Down Expand Up @@ -501,8 +502,7 @@ export class Placement {
}

stillRecent(now: number) {
return this.commitTime !== 'undefined' &&
this.commitTime + this.fadeDuration > now;
return this.commitTime + this.fadeDuration > now;
}

setStale() {
Expand Down
Loading

0 comments on commit 7b4be8d

Please sign in to comment.