Upgrade typescript, prettier, et al to continue to modernise build environment (#2519)

* Simplify nx config (no point separately caching es and js builds - they both need to be done for any code changes). Fix some no-op type definitions i.e. X extends any, and enforce templated property types as having to extend GeoJsonProperties throughout.

* Upgrade typescript. Had to update topojson-* type defs to avoid the P = GeoJsonProperties problem in geojson-rbush. Also fix a couple of floating point precision related issues that eslint now apparently catches!

* Retire tslint.

* Upgrade eslint and prettier. Add minimal prettier config (defaults have changed) to avoid widespread, minor formatting changes (trailing commas mostly).
This commit is contained in:
James Beard 2023-10-24 21:51:43 +11:00 committed by GitHub
parent 14a2ac5ead
commit e5afd5c38b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
126 changed files with 690 additions and 572 deletions

View File

@ -14,12 +14,12 @@ const rules = {
module.exports = {
root: true,
ignorePatterns: ["**/dist/**"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"plugin:prettier/recommended",
],
parserOptions: {
ecmaVersion: 6,

View File

@ -10,3 +10,10 @@ packages/turf-directional-mean/test/in/bus_route_utm.json
# is actually output
packages/turf/turf.min.js
# Ignore test fixture json in case intentional line breaks help with coord
# readability.
packages/turf-*/test/in/**
packages/turf-*/test/out/**
packages/turf-*/test/true/**
packages/turf-*/test/false/**

View File

@ -1 +1,3 @@
{}
{
"trailingComma": "es5"
}

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />

32
nx.json
View File

@ -3,17 +3,7 @@
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": [
"build",
"build:es",
"build:js",
"test",
"test:tape",
"test:types",
"last-checks",
"last-checks:example",
"last-checks:testjs"
]
"cacheableOperations": ["build", "test", "last-checks"]
}
}
},
@ -22,31 +12,11 @@
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist"]
},
"build:es": {
"dependsOn": ["^build:es"],
"outputs": ["{projectRoot}/dist"]
},
"build:js": {
"dependsOn": ["^build:js"],
"outputs": ["{projectRoot}/dist"]
},
"test": {
"dependsOn": ["^test"]
},
"test:tape": {
"dependsOn": ["^test:tape"]
},
"test:types": {
"dependsOn": ["^test:types"]
},
"last-checks": {
"dependsOn": ["^last-checks"]
},
"last-checks:example": {
"dependsOn": ["^last-checks:example"]
},
"last-checks:testjs": {
"dependsOn": ["^last-checks:testjs"]
}
}
}

View File

@ -39,9 +39,9 @@
},
"devDependencies": {
"@types/geojson": "7946.0.8",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^4.8.0",
"@typescript-eslint/parser": "^4.8.0",
"@types/node": "18.11.9",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"acorn": "^7.4.1",
"camelcase": "*",
"d3-queue": "*",
@ -49,8 +49,9 @@
"dependency-tree": "^8.1.2",
"documentation": "^14.0.2",
"es-check": "^7.1.1",
"eslint": "~7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"esm": "^3.2.25",
"fs-extra": "*",
"husky": "^4.2.3",
@ -60,13 +61,13 @@
"meow": "*",
"monorepolint": "^0.5.0-alpha.20",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"prettier": "^3.0.3",
"progress": "*",
"rollup": "^2.34.2",
"tape": "^5.7.0",
"ts-node": "^9.0.0",
"tsx": "^3.12.8",
"typescript": "^3.8.3",
"typescript": "^5.2.2",
"yamljs": "*"
}
}

View File

@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -52,7 +52,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -37,7 +37,7 @@ import { lineclip, polygonclip } from "./lib/lineclip";
*/
export default function bboxClip<
G extends Polygon | MultiPolygon | LineString | MultiLineString,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(feature: Feature<G, P> | G, bbox: BBox) {
const geom = getGeom(feature);
const type = geom.type;

View File

@ -59,7 +59,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -18,7 +18,9 @@ import { polygon, Id } from "@turf/helpers";
* //addToMap
* var addToMap = [poly]
*/
export default function bboxPolygon<P = GeoJsonProperties>(
export default function bboxPolygon<
P extends GeoJsonProperties = GeoJsonProperties,
>(
bbox: BBox,
options: {
properties?: P;

View File

@ -52,7 +52,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -53,7 +53,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -50,7 +50,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -33,7 +33,7 @@ import Spline from "./lib/spline";
* var addToMap = [line, curved]
* curved.properties = { stroke: '#0F0' };
*/
function bezier<P = GeoJsonProperties>(
function bezier<P extends GeoJsonProperties = GeoJsonProperties>(
line: Feature<LineString> | LineString,
options: {
properties?: P;

View File

@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -59,7 +59,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -62,7 +62,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -61,7 +61,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -55,7 +55,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -38,7 +38,7 @@ import { getCoord, getGeom } from "@turf/invariant";
*/
export default function booleanPointInPolygon<
G extends Polygon | MultiPolygon,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
point: Coord,
polygon: Feature<G, P> | G,

View File

@ -53,7 +53,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -54,7 +54,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -61,7 +61,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -59,7 +59,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -61,7 +61,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -28,7 +28,7 @@ import { isNumber, point, Id } from "@turf/helpers";
* mean.properties['marker-size'] = 'large';
* mean.properties['marker-color'] = '#000';
*/
function centerMean<P = GeoJsonProperties>(
function centerMean<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: any, // To-Do include Typescript AllGeoJSON
options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}
): Feature<Point, P> {

View File

@ -62,7 +62,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -21,7 +21,7 @@ import { coordEach } from "@turf/meta";
* //addToMap
* var addToMap = [polygon, center]
*/
function centerOfMass<P = GeoJsonProperties>(
function centerOfMass<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: any,
options: {
properties?: P;

View File

@ -52,7 +52,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -26,7 +26,7 @@ import { point, Id, AllGeoJSON } from "@turf/helpers";
* center.properties['marker-size'] = 'large';
* center.properties['marker-color'] = '#000';
*/
function center<P = GeoJsonProperties>(
function center<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: AllGeoJSON,
options: { properties?: P; bbox?: BBox; id?: Id } = {}
): Feature<Point, P> {

View File

@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -18,7 +18,7 @@ import { coordEach } from "@turf/meta";
* //addToMap
* var addToMap = [polygon, centroid]
*/
function centroid<P = GeoJsonProperties>(
function centroid<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: AllGeoJSON,
options: {
properties?: P;

View File

@ -55,7 +55,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -22,7 +22,7 @@ import { polygon, Units } from "@turf/helpers";
* //addToMap
* var addToMap = [turf.point(center), circle]
*/
function circle<P = GeoJsonProperties>(
function circle<P extends GeoJsonProperties = GeoJsonProperties>(
center: number[] | Point | Feature<Point, P>,
radius: number,
options: {

View File

@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -56,7 +56,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -54,7 +54,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -66,7 +66,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -67,7 +67,6 @@
"matrix-to-grid": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -1,4 +1,9 @@
import { Feature, FeatureCollection, GeometryObject } from "geojson";
import {
Feature,
FeatureCollection,
GeoJsonProperties,
GeometryObject,
} from "geojson";
import { featureEach } from "@turf/meta";
import { featureCollection } from "@turf/helpers";
@ -31,10 +36,10 @@ import { featureCollection } from "@turf/helpers";
* turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
* //= 1
*/
export function getCluster<G extends GeometryObject, P = any>(
geojson: FeatureCollection<G, P>,
filter: any
): FeatureCollection<G, P> {
export function getCluster<
G extends GeometryObject,
P extends GeoJsonProperties = GeoJsonProperties,
>(geojson: FeatureCollection<G, P>, filter: any): FeatureCollection<G, P> {
// Validation
if (!geojson) throw new Error("geojson is required");
if (geojson.type !== "FeatureCollection")
@ -99,7 +104,10 @@ export function getCluster<G extends GeometryObject, P = any>(
* values.push(clusterValue);
* });
*/
export function clusterEach<G extends GeometryObject, P = any>(
export function clusterEach<
G extends GeometryObject,
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson: FeatureCollection<G, P>,
property: number | string,
callback: (
@ -193,7 +201,10 @@ export function clusterEach<G extends GeometryObject, P = any>(
* return previousValue.concat(clusterValue);
* }, []);
*/
export function clusterReduce<G extends GeometryObject, P = any>(
export function clusterReduce<
G extends GeometryObject,
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson: FeatureCollection<G, P>,
property: number | string,
callback: (

View File

@ -56,7 +56,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -57,7 +57,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -52,7 +52,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -59,13 +59,12 @@
},
"devDependencies": {
"@types/tape": "*",
"@types/topojson-client": "^3.0.0",
"@types/topojson-server": "^3.0.0",
"@types/topojson-client": "3.1.3",
"@types/topojson-server": "3.0.3",
"benchmark": "*",
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -31,7 +31,7 @@ import concaveman from "concaveman";
* //addToMap
* var addToMap = [points, hull]
*/
export default function convex<P = GeoJsonProperties>(
export default function convex<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: AllGeoJSON,
options: {
concavity?: number;

View File

@ -52,7 +52,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -37,7 +37,9 @@ import { getCoord } from "@turf/invariant";
* destination.properties['marker-color'] = '#f00';
* point.properties['marker-color'] = '#0f0';
*/
export default function destination<P = GeoJsonProperties>(
export default function destination<
P extends GeoJsonProperties = GeoJsonProperties,
>(
origin: Coord,
distance: number,
bearing: number,

View File

@ -56,7 +56,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -52,7 +52,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -137,7 +137,7 @@ export const areaFactors: Record<AreaUnits, number> = {
*/
export function feature<
G extends GeometryObject = Geometry,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
geom: G | null,
properties?: P,
@ -214,7 +214,7 @@ export function geometry(
*
* //=point
*/
export function point<P = GeoJsonProperties>(
export function point<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position,
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -259,7 +259,7 @@ export function point<P = GeoJsonProperties>(
*
* //=points
*/
export function points<P = GeoJsonProperties>(
export function points<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position[],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -287,7 +287,7 @@ export function points<P = GeoJsonProperties>(
*
* //=polygon
*/
export function polygon<P = GeoJsonProperties>(
export function polygon<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position[][],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -335,7 +335,7 @@ export function polygon<P = GeoJsonProperties>(
*
* //=polygons
*/
export function polygons<P = GeoJsonProperties>(
export function polygons<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position[][][],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -365,7 +365,7 @@ export function polygons<P = GeoJsonProperties>(
* //=linestring1
* //=linestring2
*/
export function lineString<P = GeoJsonProperties>(
export function lineString<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position[],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -399,7 +399,7 @@ export function lineString<P = GeoJsonProperties>(
*
* //=linestrings
*/
export function lineStrings<P = GeoJsonProperties>(
export function lineStrings<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position[][],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -436,7 +436,7 @@ export function lineStrings<P = GeoJsonProperties>(
*/
export function featureCollection<
G extends GeometryObject = Geometry,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
features: Array<Feature<G, P>>,
options: { bbox?: BBox; id?: Id } = {}
@ -469,7 +469,9 @@ export function featureCollection<
*
* //=multiLine
*/
export function multiLineString<P = GeoJsonProperties>(
export function multiLineString<
P extends GeoJsonProperties = GeoJsonProperties,
>(
coordinates: Position[][],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -498,7 +500,7 @@ export function multiLineString<P = GeoJsonProperties>(
*
* //=multiPt
*/
export function multiPoint<P = GeoJsonProperties>(
export function multiPoint<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position[],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -528,7 +530,7 @@ export function multiPoint<P = GeoJsonProperties>(
* //=multiPoly
*
*/
export function multiPolygon<P = GeoJsonProperties>(
export function multiPolygon<P extends GeoJsonProperties = GeoJsonProperties>(
coordinates: Position[][][],
properties?: P,
options: { bbox?: BBox; id?: Id } = {}
@ -558,7 +560,9 @@ export function multiPolygon<P = GeoJsonProperties>(
*
* // => collection
*/
export function geometryCollection<P = GeoJsonProperties>(
export function geometryCollection<
P extends GeoJsonProperties = GeoJsonProperties,
>(
geometries: Array<
Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon
>,

View File

@ -58,7 +58,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -642,7 +642,7 @@ test("turf-helpers -- isNumber", (t) => {
t.true(isNumber("123"));
t.true(isNumber(+"123"));
t.true(isNumber("1e10000"));
t.true(isNumber(1e10000));
t.true(isNumber(1e100));
t.true(isNumber(Infinity));
t.true(isNumber(-Infinity));

View File

@ -152,7 +152,7 @@ isNumber(-123);
isNumber("123");
isNumber(+"123");
isNumber("1e10000");
isNumber(1e10000);
isNumber(1e100);
isNumber(Infinity);
isNumber(-Infinity);

View File

@ -1,6 +1,7 @@
const Benchmark = require("benchmark");
const grid = require("./index").default;
// prettier-ignore
var bbox = [
-96.6357421875,
31.12819929911196,

View File

@ -34,7 +34,7 @@ import { polygon, featureCollection, Units } from "@turf/helpers";
* //addToMap
* var addToMap = [hexgrid];
*/
function hexGrid<P = GeoJsonProperties>(
function hexGrid<P extends GeoJsonProperties = GeoJsonProperties>(
bbox: BBox,
cellSide: number,
options: {

View File

@ -65,7 +65,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -1,6 +1,7 @@
import { BBox } from "geojson";
import hexGrid from "./index";
// prettier-ignore
const bbox: BBox = [
-96.6357421875,
31.12819929911196,

View File

@ -44,7 +44,9 @@ import polygonClipping from "polygon-clipping";
* //addToMap
* var addToMap = [poly1, poly2, intersection];
*/
export default function intersect<P = GeoJsonProperties>(
export default function intersect<
P extends GeoJsonProperties = GeoJsonProperties,
>(
features: FeatureCollection<Polygon | MultiPolygon>,
options: {
properties?: P;

View File

@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -71,7 +71,7 @@ export function getCoords<
| Polygon
| MultiPoint
| MultiLineString
| MultiPolygon
| MultiPolygon,
>(coords: any[] | Feature<G> | G): any[] {
if (Array.isArray(coords)) {
return coords;

View File

@ -54,7 +54,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -1626,7 +1626,15 @@ function computeBandGrid(data, minV, bandwidth) {
lefttop,
leftbottom;
topleft = topright = bottomleft = bottomright = righttop = rightbottom = lefttop = leftbottom = 0.5;
topleft =
topright =
bottomleft =
bottomright =
righttop =
rightbottom =
lefttop =
leftbottom =
0.5;
var edges = [];

View File

@ -65,7 +65,6 @@
"npm-run-all": "*",
"rollup": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -64,7 +64,6 @@
"npm-run-all": "*",
"rollup": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -33,7 +33,7 @@ import { point } from "@turf/helpers";
* var addToMap = [poly, kinks]
*/
export default function kinks<
T extends LineString | MultiLineString | Polygon | MultiPolygon
T extends LineString | MultiLineString | Polygon | MultiPolygon,
>(featureIn: Feature<T>): FeatureCollection<Point> {
const results: FeatureCollection<Point> = {
type: "FeatureCollection",

View File

@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -30,7 +30,7 @@ import findIntersections, { Intersection } from "sweepline-intersections";
*/
function lineIntersect<
G1 extends LineString | MultiLineString | Polygon | MultiPolygon,
G2 extends LineString | MultiLineString | Polygon | MultiPolygon
G2 extends LineString | MultiLineString | Polygon | MultiPolygon,
>(
line1: FeatureCollection<G1> | Feature<G1> | G1,
line2: FeatureCollection<G2> | Feature<G2> | G2,

View File

@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -36,7 +36,7 @@ import equal from "deep-equal";
*/
function lineOverlap<
G1 extends LineString | MultiLineString | Polygon | MultiPolygon,
G2 extends LineString | MultiLineString | Polygon | MultiPolygon
G2 extends LineString | MultiLineString | Polygon | MultiPolygon,
>(
line1: Feature<G1> | G1,
line2: Feature<G2> | G2,

View File

@ -58,7 +58,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -26,7 +26,7 @@ import { flattenEach } from "@turf/meta";
* var addToMap = [polygon, segments]
*/
function lineSegment<
G extends LineString | MultiLineString | Polygon | MultiPolygon
G extends LineString | MultiLineString | Polygon | MultiPolygon,
>(
geojson: Feature<G> | FeatureCollection<G> | G
): FeatureCollection<LineString> {

View File

@ -51,7 +51,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -7,7 +7,7 @@ var route1 = JSON.parse(fs.readFileSync(__dirname + "/test/in/route1.geojson"));
var route2 = JSON.parse(fs.readFileSync(__dirname + "/test/in/route2.geojson"));
var line1 = JSON.parse(fs.readFileSync(__dirname + "/test/in/line1.geojson"));
var start1 = point([-97.79617309570312, 22.254624939561698]);
var start1 = point([-97.79617309570313, 22.254624939561698]);
var stop1 = point([-97.72750854492188, 22.057641623615734]);
var start2 = point([-79.0850830078125, 37.60117623656667]);
var stop2 = point([-77.7667236328125, 38.65119833229951]);

View File

@ -57,7 +57,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -17,7 +17,7 @@ import { AllGeoJSON, Lines, Id } from "@turf/helpers";
/**
* http://turfjs.org/docs/#coordreduce
*/
export function coordReduce<Reducer extends any>(
export function coordReduce<Reducer>(
geojson: AllGeoJSON,
callback: (
previousValue: Reducer,
@ -56,7 +56,10 @@ export function propEach<Props extends GeoJsonProperties>(
/**
* http://turfjs.org/docs/#propreduce
*/
export function propReduce<Reducer extends any, P = GeoJsonProperties>(
export function propReduce<
Reducer,
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson: Feature<any, P> | FeatureCollection<any, P> | Geometry,
callback: (
previousValue: Reducer,
@ -70,9 +73,9 @@ export function propReduce<Reducer extends any, P = GeoJsonProperties>(
* http://turfjs.org/docs/#featurereduce
*/
export function featureReduce<
Reducer extends any,
Reducer,
G extends GeometryObject,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| Feature<G, P>
@ -89,7 +92,10 @@ export function featureReduce<
/**
* http://turfjs.org/docs/#featureeach
*/
export function featureEach<G extends GeometryObject, P = GeoJsonProperties>(
export function featureEach<
G extends GeometryObject,
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| Feature<G, P>
| FeatureCollection<G, P>
@ -106,9 +112,9 @@ export function coordAll(geojson: AllGeoJSON): number[][];
* http://turfjs.org/docs/#geomreduce
*/
export function geomReduce<
Reducer extends any,
Reducer,
G extends GeometryObject,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| Feature<G, P>
@ -132,7 +138,7 @@ export function geomReduce<
*/
export function geomEach<
G extends GeometryObject | null,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| Feature<G, P>
@ -153,9 +159,9 @@ export function geomEach<
* http://turfjs.org/docs/#flattenreduce
*/
export function flattenReduce<
Reducer extends any,
Reducer,
G extends GeometryObject,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| Feature<G, P>
@ -177,7 +183,7 @@ export function flattenReduce<
*/
export function flattenEach<
G extends GeometryObject = GeometryObject,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| Feature<G, P>
@ -195,7 +201,10 @@ export function flattenEach<
/**
* http://turfjs.org/docs/#segmentreduce
*/
export function segmentReduce<Reducer extends any, P = GeoJsonProperties>(
export function segmentReduce<
Reducer,
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| FeatureCollection<Lines, P>
| Feature<Lines, P>
@ -216,7 +225,7 @@ export function segmentReduce<Reducer extends any, P = GeoJsonProperties>(
/**
* http://turfjs.org/docs/#segmenteach
*/
export function segmentEach<P = GeoJsonProperties>(
export function segmentEach<P extends GeoJsonProperties = GeoJsonProperties>(
geojson: AllGeoJSON,
callback: (
currentSegment?: Feature<LineString, P>,
@ -230,7 +239,10 @@ export function segmentEach<P = GeoJsonProperties>(
/**
* http://turfjs.org/docs/#linereduce
*/
export function lineReduce<Reducer extends any, P = GeoJsonProperties>(
export function lineReduce<
Reducer,
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson:
| FeatureCollection<Lines, P>
| Feature<Lines, P>
@ -250,7 +262,7 @@ export function lineReduce<Reducer extends any, P = GeoJsonProperties>(
/**
* http://turfjs.org/docs/#lineeach
*/
export function lineEach<P = GeoJsonProperties>(
export function lineEach<P extends GeoJsonProperties = GeoJsonProperties>(
geojson:
| FeatureCollection<Lines, P>
| Feature<Lines, P>
@ -270,7 +282,7 @@ export function lineEach<P = GeoJsonProperties>(
*/
export function findSegment<
G extends LineString | MultiLineString | Polygon | MultiPolygon,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson: Feature<G, P> | FeatureCollection<G, P> | G,
options?: {
@ -287,7 +299,10 @@ export function findSegment<
/**
* http://turfjs.org/docs/#findpoint
*/
export function findPoint<G extends GeometryObject, P = GeoJsonProperties>(
export function findPoint<
G extends GeometryObject,
P extends GeoJsonProperties = GeoJsonProperties,
>(
geojson: Feature<G, P> | FeatureCollection<G, P> | G,
options?: {
featureIndex?: number;

View File

@ -1209,23 +1209,10 @@ test("meta.coordEach -- indexes -- Multi-Polygon with hole", (t) => {
);
t.deepEqual(featureIndexes, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
t.deepEqual(multiFeatureIndexes, [
0,
0,
0,
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
]);
t.deepEqual(
multiFeatureIndexes,
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
);
t.deepEqual(geometryIndexes, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]);
t.deepEqual(coordIndexes, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]);
// Major Release Change v6.x

View File

@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -54,7 +54,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -50,7 +50,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -60,7 +60,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -54,7 +54,6 @@
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*"
},

View File

@ -32,7 +32,7 @@ import { point, featureCollection, Units } from "@turf/helpers";
* //addToMap
* var addToMap = [grid];
*/
function pointGrid<P = GeoJsonProperties>(
function pointGrid<P extends GeoJsonProperties = GeoJsonProperties>(
bbox: BBox,
cellSide: number,
options: {

View File

@ -59,7 +59,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -56,7 +56,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

View File

@ -14,7 +14,7 @@ import {
export default function pointsWithinPolygon<
F extends Point | MultiPoint,
G extends Polygon | MultiPolygon,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
points: Feature<F, P> | FeatureCollection<F, P>,
polygons: Feature<G> | FeatureCollection<G> | G

View File

@ -29,7 +29,7 @@ import { getGeom } from "@turf/invariant";
*/
export default function <
G extends Polygon | MultiPolygon,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
poly: Feature<G, P> | G,
options: { properties?: any } = {}
@ -53,7 +53,10 @@ export default function <
/**
* @private
*/
export function polygonToLine<G extends Polygon, P = GeoJsonProperties>(
export function polygonToLine<
G extends Polygon,
P extends GeoJsonProperties = GeoJsonProperties,
>(
poly: Feature<G, P> | G,
options: { properties?: any } = {}
): Feature<LineString | MultiLineString, P> {
@ -73,7 +76,7 @@ export function polygonToLine<G extends Polygon, P = GeoJsonProperties>(
*/
export function multiPolygonToLine<
G extends MultiPolygon,
P = GeoJsonProperties
P extends GeoJsonProperties = GeoJsonProperties,
>(
multiPoly: Feature<G, P> | G,
options: { properties?: P } = {}
@ -96,7 +99,7 @@ export function multiPolygonToLine<
/**
* @private
*/
export function coordsToLine<P = GeoJsonProperties>(
export function coordsToLine<P extends GeoJsonProperties = GeoJsonProperties>(
coords: number[][][],
properties: P
): Feature<LineString | MultiLineString, P> {

View File

@ -53,7 +53,6 @@
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"tslint": "*",
"tsx": "*",
"typescript": "*",
"write-json-file": "*"

Some files were not shown because too many files have changed in this diff Show More