Skip to content

Commit

Permalink
Add flow typechecking infrastructure (#3397)
Browse files Browse the repository at this point in the history
* Add unflowify to build process

* Use "flow-bin" rather than "flow"

* Add "flow-remove-types" to render & query tests

* Simplified diff

* Upgrade flow-bin version
  • Loading branch information
Lucas Wojciechowski committed Nov 1, 2016
1 parent 8127e17 commit b1e23e6
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 118 deletions.
7 changes: 7 additions & 0 deletions .eslintrc
@@ -1,5 +1,12 @@
{
"extends": "mourner",
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "script",
},
"plugins": [
"flowtype"
],
"rules": {
"array-bracket-spacing": "off",
"block-scoped-var": "error",
Expand Down
11 changes: 11 additions & 0 deletions .flowconfig
@@ -0,0 +1,11 @@
[ignore]

.*/node_modules/.*

[include]

[libs]

./interfaces/

[options]
4 changes: 4 additions & 0 deletions interfaces/mapbox-gl-js-test.js
@@ -0,0 +1,4 @@
declare module "mapbox-gl-js-test" {
declare type CreateTest = (name: string, body: (test: CreateTest) => void) => void;
declare var exports: CreateTest;
}
40 changes: 40 additions & 0 deletions interfaces/point-geometry.js
@@ -0,0 +1,40 @@
declare module "point-geometry" {
declare class Point {
x: number;
y: number;
clone(): Point;
add(point: Point): Point;
sub(point: Point): Point;
multByPoint(point: Point): Point;
divByPoint(point: Point): Point;
mult(k: number): Point;
div(k: number): Point;
rotate(angle: number): Point;
rotateAround(angle: number, point: Point): Point;
matMult(matrix: [number, number, number, number]): Point;
unit(): Point;
perp(): Point;
round(): Point;
mag(): number;
equals(point: Point): boolean;
dist(point: Point): number;
distSqr(point: Point): number;
angle(): number;
angleTo(point: Point): number;
angleWith(point: Point): number;
angleWithSep(x: number, y: number): number;
_matMult(matrix: [number, number, number, number]): Point;
_add(point: Point): Point;
_sub(point: Point): Point;
_mult(k: number): Point;
_div(k: number): Point;
_multByPoint(point: Point): Point;
_divByPoint(point: Point): Point;
_unit(): Point;
_perp(): Point;
_rotate(angle: number): Point;
_rotateAround(angle: number, point: Point): Point;
_round(): Point;
}
declare var exports: typeof Point;
}
11 changes: 11 additions & 0 deletions interfaces/unitbezier.js
@@ -0,0 +1,11 @@
declare module "unitbezier" {
declare class UnitBezier {
constructor(p1x: number, p1y: number, p2x: number, p2y: number): UnitBezier;
sampleCurveX(t: number): number;
sampleCurveY(t: number): number;
sampleCurveDerivativeX(t: number): number;
solveCurveX(t: number): number;
solve(x: number, epsilon?: number): number;
}
declare var exports: typeof UnitBezier;
}
2 changes: 1 addition & 1 deletion js/style/parse_color.js
Expand Up @@ -8,7 +8,7 @@ const cache = {};

module.exports = function parseColor(input) {

if (StyleFunction.isFunctionDefinition(input)) {
if (input && StyleFunction.isFunctionDefinition(input)) {

if (!input.stops) return input;
else return util.extend({}, input, {
Expand Down

0 comments on commit b1e23e6

Please sign in to comment.