diff --git a/.monorepolint.config.mjs b/.monorepolint.config.mjs index 28fc660344..d7b8e13820 100644 --- a/.monorepolint.config.mjs +++ b/.monorepolint.config.mjs @@ -1,55 +1,55 @@ // @ts-check -import * as path from "node:path"; -import { glob } from "glob"; -import * as fs from "node:fs"; import { alphabeticalDependencies, alphabeticalScripts, + fileContents, packageOrder, packageEntry, packageScript, requireDependency, } from "@monorepolint/rules"; -const TS_PACKAGES = []; // projects that use typescript to build -const JS_PACKAGES = []; // projects that use javascript/rollup to build const MAIN_PACKAGE = "@turf/turf"; -const TAPE_PACKAGES = []; // projects that have tape tests -const TYPES_PACKAGES = []; // projects that have types tests -const BENCH_PACKAGES = []; // projects that have benchmarks - -// iterate all the packages and figure out what buckets everything falls into -const __dirname = new URL(".", import.meta.url).pathname; -glob.sync(path.join(__dirname, "packages", "turf-*")).forEach((pk) => { - const name = JSON.parse( - fs.readFileSync(path.join(pk, "package.json"), "utf8") - ).name; - - if (fs.existsSync(path.join(pk, "index.ts"))) { - TS_PACKAGES.push(name); - } else { - JS_PACKAGES.push(name); - } - - if (fs.existsSync(path.join(pk, "test.js"))) { - TAPE_PACKAGES.push(name); - } - - if (fs.existsSync(path.join(pk, "types.ts"))) { - TYPES_PACKAGES.push(name); - } -}); - -const TS_TAPE_PACKAGES = TAPE_PACKAGES.filter( - (pkg) => -1 !== TS_PACKAGES.indexOf(pkg) -); -const JS_TAPE_PACKAGES = TAPE_PACKAGES.filter( - (pkg) => -1 !== JS_PACKAGES.indexOf(pkg) -); - export default { rules: [ + fileContents({ + options: { + file: "tsconfig.json", + template: `{ + "extends": "../../tsconfig.shared.json" +} +`, + }, + excludePackages: ["@turf/isobands", "@turf/isolines", "@turf/tesselate"], + }), + + // Special treatment for three packages with locally defined .d.ts files for + // untyped Javascript dependencies. Might be possible to remove should those + // libraries be retired / types added to DefinitelyTyped. + fileContents({ + options: { + file: "tsconfig.json", + template: `{ + "extends": "../../tsconfig.shared.json", + "files": ["index.ts", "marchingsquares.d.ts"] +} +`, + }, + includePackages: ["@turf/isobands", "@turf/isolines"], + }), + fileContents({ + options: { + file: "tsconfig.json", + template: `{ + "extends": "../../tsconfig.shared.json", + "files": ["index.ts", "earcut.d.ts"] +} +`, + }, + includePackages: ["@turf/tesselate"], + }), + packageOrder({ options: { order: [ @@ -86,41 +86,8 @@ export default { }), alphabeticalDependencies({ includeWorkspaceRoot: true }), alphabeticalScripts({ includeWorkspaceRoot: true }), - packageEntry({ - options: { - entries: { - type: "module", - main: "dist/cjs/index.cjs", - module: "dist/esm/index.js", - types: "dist/esm/index.d.ts", - sideEffects: false, - publishConfig: { - access: "public", - }, - // @turf/turf is commonly consumed through CDNs, moving this output file is a breaking change for anyone - // who has a hardcoded reference to this specific file, instead of letting the CDN pick the path. - // Example of a URL that will break: https://unpkg.com/@turf/turf/dist/turf.min.js - // Example of a URL that will keep working: https://unpkg.com/@turf/turf - browser: "turf.min.js", - files: ["dist", "turf.min.js"], - exports: { - "./package.json": "./package.json", - ".": { - import: { - types: "./dist/esm/index.d.ts", - default: "./dist/esm/index.js", - }, - require: { - types: "./dist/cjs/index.d.cts", - default: "./dist/cjs/index.cjs", - }, - }, - }, - }, - }, - includePackages: [MAIN_PACKAGE], - }), + // All packages ... packageEntry({ options: { entries: { @@ -129,6 +96,7 @@ export default { module: "dist/esm/index.js", types: "dist/esm/index.d.ts", sideEffects: false, + funding: "https://opencollective.com/turf", publishConfig: { access: "public", }, @@ -147,24 +115,29 @@ export default { }, }, }, - includePackages: [...TS_PACKAGES, ...JS_PACKAGES], }), - + // All except @turf/turf packageEntry({ options: { entries: { files: ["dist"], }, }, - includePackages: [...TS_PACKAGES, ...JS_PACKAGES], + excludePackages: [MAIN_PACKAGE], }), - + // @turf/turf only packageEntry({ options: { entries: { - funding: "https://opencollective.com/turf", + // @turf/turf is commonly consumed through CDNs, moving this output file is a breaking change for anyone + // who has a hardcoded reference to this specific file, instead of letting the CDN pick the path. + // Example of a URL that will break: https://unpkg.com/@turf/turf/dist/turf.min.js + // Example of a URL that will keep working: https://unpkg.com/@turf/turf + browser: "turf.min.js", + files: ["dist", "turf.min.js"], }, }, + includePackages: [MAIN_PACKAGE], }), packageScript({ @@ -172,6 +145,8 @@ export default { scripts: { docs: "tsx ../../scripts/generate-readmes.ts", test: "npm-run-all --npm-path npm test:*", + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit", }, }, excludePackages: [MAIN_PACKAGE], @@ -183,63 +158,24 @@ export default { build: "tsup --config ../../tsup.config.ts", }, }, - includePackages: [...TS_PACKAGES, ...JS_PACKAGES], - }), - - packageScript({ - options: { - scripts: { - build: - "tsup --config ../../tsup.config.ts && rollup -c rollup.config.js", - }, - }, - includePackages: [MAIN_PACKAGE], - }), - - packageScript({ - options: { - scripts: { - bench: "tsx bench.ts", - "test:tape": "tsx test.ts", - }, - }, - includePackages: [...TS_TAPE_PACKAGES, ...JS_TAPE_PACKAGES], - }), - - packageScript({ - options: { - scripts: { - "test:types": - "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts", - }, - }, - includePackages: TYPES_PACKAGES, - }), - - requireDependency({ - options: { - devDependencies: { - benchmark: "^2.1.4", - "npm-run-all": "^4.1.5", - tape: "^5.7.2", - tsx: "^4.6.2", - }, - }, - includePackages: [...TS_PACKAGES, ...JS_PACKAGES], }), requireDependency({ options: { dependencies: { + "@types/geojson": "^7946.0.10", tslib: "^2.6.2", }, devDependencies: { "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", + benchmark: "^2.1.4", + "npm-run-all": "^4.1.5", + tape: "^5.7.2", + tsx: "^4.6.2", typescript: "^5.5.4", }, }, - includePackages: TS_PACKAGES, }), requireDependency({ @@ -250,14 +186,5 @@ export default { }, includePackages: [MAIN_PACKAGE], }), - - requireDependency({ - options: { - dependencies: { - "@types/geojson": "^7946.0.10", - }, - }, - includePackages: [MAIN_PACKAGE, ...TS_PACKAGES, ...JS_PACKAGES], - }), ], }; diff --git a/nx.json b/nx.json index 87f3cd2f1b..8bae838462 100644 --- a/nx.json +++ b/nx.json @@ -28,7 +28,7 @@ "{projectRoot}/test/**", "{projectRoot}/types.ts" ], - "dependsOn": ["build"], + "dependsOn": [], "cache": true }, "last-checks": { diff --git a/package.json b/package.json index 0dffa5ad36..87c1039c19 100644 --- a/package.json +++ b/package.json @@ -3,17 +3,19 @@ "funding": "https://opencollective.com/turf", "scripts": { "docs": "tsx ./scripts/generate-readmes.ts", + "escheck": "npm-run-all escheck:*", + "escheck:cjs": "es-check es8 packages/*/dist/cjs/index.cjs packages/turf/turf.min.js", + "escheck:esm": "es-check --module es8 packages/*/dist/esm/index.js", + "escheck:web": "es-check es5 packages/turf/turf.min.js", "lint": "npm-run-all lint:*", "lint:docs": "documentation lint packages/turf-*/index.js", - "lint:escheck-cjs": "es-check es8 packages/*/dist/cjs/index.cjs packages/turf/turf.min.js", - "lint:escheck-esm": "es-check --module es8 packages/*/dist/esm/index.js", - "lint:escheck-web": "es-check es5 packages/turf/turf.min.js", "lint:eslint": "eslint packages", "lint:mrl": "mrl check", "lint:prettier": "prettier --check .", + "postinstall": "husky install", "preinstall": "npx only-allow pnpm", - "prepare": "husky && lerna run build", - "test": "pnpm run lint && lerna run test && lerna run --scope @turf/turf last-checks" + "prepublishOnly": "lerna run build && lerna run --scope @turf/turf cdnBundle && pnpm run escheck", + "test": "pnpm run lint && lerna run test" }, "lint-staged": { "package.json": [ @@ -34,8 +36,8 @@ "@monorepolint/core": "0.5.0-alpha.132", "@monorepolint/rules": "0.5.0-alpha.132", "@types/node": "18.11.9", - "@typescript-eslint/eslint-plugin": "^6.10.0", - "@typescript-eslint/parser": "^6.10.0", + "@typescript-eslint/eslint-plugin": "^8.2.0", + "@typescript-eslint/parser": "^8.2.0", "acorn": "^7.4.1", "camelcase": "^8.0.0", "d3-queue": "*", @@ -43,7 +45,7 @@ "dependency-tree": "^11.0.0", "documentation": "^14.0.3", "es-check": "^7.1.1", - "eslint": "^8.53.0", + "eslint": "^8.57.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.1", "esm": "^3.2.25", diff --git a/packages/turf-along/package.json b/packages/turf-along/package.json index ac5ab3b40b..dd9ffa8e03 100644 --- a/packages/turf-along/package.json +++ b/packages/turf-along/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-angle/package.json b/packages/turf-angle/package.json index 02a97d006c..c27e2b3b05 100644 --- a/packages/turf-angle/package.json +++ b/packages/turf-angle/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/distance": "workspace:^", diff --git a/packages/turf-area/package.json b/packages/turf-area/package.json index c25b824e8f..4fb6c8c48f 100644 --- a/packages/turf-area/package.json +++ b/packages/turf-area/package.json @@ -48,7 +48,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-bbox-clip/package.json b/packages/turf-bbox-clip/package.json index 11cbc4aebc..7d9a178dc3 100644 --- a/packages/turf-bbox-clip/package.json +++ b/packages/turf-bbox-clip/package.json @@ -54,7 +54,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox": "workspace:^", diff --git a/packages/turf-bbox-polygon/package.json b/packages/turf-bbox-polygon/package.json index 53b5d35ea1..167c2161d9 100644 --- a/packages/turf-bbox-polygon/package.json +++ b/packages/turf-bbox-polygon/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-bbox/package.json b/packages/turf-bbox/package.json index 35783b046b..f5551547f5 100644 --- a/packages/turf-bbox/package.json +++ b/packages/turf-bbox/package.json @@ -50,7 +50,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-bearing/package.json b/packages/turf-bearing/package.json index 2c2ca13c8a..1ec2b8874a 100644 --- a/packages/turf-bearing/package.json +++ b/packages/turf-bearing/package.json @@ -46,7 +46,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/destination": "workspace:^", diff --git a/packages/turf-bezier-spline/package.json b/packages/turf-bezier-spline/package.json index 53c7e89a96..0e5e6d0c73 100644 --- a/packages/turf-bezier-spline/package.json +++ b/packages/turf-bezier-spline/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-clockwise/package.json b/packages/turf-boolean-clockwise/package.json index 54c09215b0..8824915543 100755 --- a/packages/turf-boolean-clockwise/package.json +++ b/packages/turf-boolean-clockwise/package.json @@ -53,7 +53,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-concave/package.json b/packages/turf-boolean-concave/package.json index 57bc447c88..91a4be80f3 100644 --- a/packages/turf-boolean-concave/package.json +++ b/packages/turf-boolean-concave/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-contains/package.json b/packages/turf-boolean-contains/package.json index 26f07f01ba..8f83b86cee 100644 --- a/packages/turf-boolean-contains/package.json +++ b/packages/turf-boolean-contains/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-crosses/package.json b/packages/turf-boolean-crosses/package.json index 4efabdfe89..e9d0844fad 100644 --- a/packages/turf-boolean-crosses/package.json +++ b/packages/turf-boolean-crosses/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-disjoint/package.json b/packages/turf-boolean-disjoint/package.json index 58602d5cc3..f9235503cf 100644 --- a/packages/turf-boolean-disjoint/package.json +++ b/packages/turf-boolean-disjoint/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-equal/package.json b/packages/turf-boolean-equal/package.json index 240f075fbf..53edda4150 100644 --- a/packages/turf-boolean-equal/package.json +++ b/packages/turf-boolean-equal/package.json @@ -55,7 +55,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-intersects/package.json b/packages/turf-boolean-intersects/package.json index a58594378f..d7cf2d9108 100644 --- a/packages/turf-boolean-intersects/package.json +++ b/packages/turf-boolean-intersects/package.json @@ -53,7 +53,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-overlap/package.json b/packages/turf-boolean-overlap/package.json index d5f9c1465d..8ede3eef68 100755 --- a/packages/turf-boolean-overlap/package.json +++ b/packages/turf-boolean-overlap/package.json @@ -54,7 +54,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-parallel/package.json b/packages/turf-boolean-parallel/package.json index 36e629ff19..2505da48b7 100644 --- a/packages/turf-boolean-parallel/package.json +++ b/packages/turf-boolean-parallel/package.json @@ -51,7 +51,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-point-in-polygon/package.json b/packages/turf-boolean-point-in-polygon/package.json index 8e90e8bcdc..6cd32f1784 100644 --- a/packages/turf-boolean-point-in-polygon/package.json +++ b/packages/turf-boolean-point-in-polygon/package.json @@ -50,7 +50,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-point-on-line/package.json b/packages/turf-boolean-point-on-line/package.json index 74c354e8fb..5c0f60e10f 100644 --- a/packages/turf-boolean-point-on-line/package.json +++ b/packages/turf-boolean-point-on-line/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-touches/package.json b/packages/turf-boolean-touches/package.json index 1c7c696857..a382898738 100644 --- a/packages/turf-boolean-touches/package.json +++ b/packages/turf-boolean-touches/package.json @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-touches/types.ts b/packages/turf-boolean-touches/types.ts deleted file mode 100644 index cafd1accb6..0000000000 --- a/packages/turf-boolean-touches/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import * as helpers from "@turf/helpers"; -import { booleanTouches } from "./index.js"; - -const pt = helpers.point([0, 0]); -const line = helpers.lineString([ - [0, 0], - [10, 10], -]); -booleanTouches(pt, line); diff --git a/packages/turf-boolean-valid/package.json b/packages/turf-boolean-valid/package.json index f98b989128..a2d5dc062e 100644 --- a/packages/turf-boolean-valid/package.json +++ b/packages/turf-boolean-valid/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-within/package.json b/packages/turf-boolean-within/package.json index 65f7b9d2fb..eb600c5320 100644 --- a/packages/turf-boolean-within/package.json +++ b/packages/turf-boolean-within/package.json @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-boolean-within/types.ts b/packages/turf-boolean-within/types.ts deleted file mode 100644 index 190bcfd689..0000000000 --- a/packages/turf-boolean-within/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import * as helpers from "@turf/helpers"; -import { booleanWithin } from "./index.js"; - -const pt = helpers.point([0, 0]); -const line = helpers.lineString([ - [0, 0], - [10, 10], -]); -booleanWithin(pt, line); diff --git a/packages/turf-buffer/package.json b/packages/turf-buffer/package.json index f2b0c0a80f..fc8ac30048 100644 --- a/packages/turf-buffer/package.json +++ b/packages/turf-buffer/package.json @@ -57,7 +57,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", @@ -69,6 +69,7 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { @@ -79,6 +80,7 @@ "@turf/meta": "workspace:^", "@turf/projection": "workspace:^", "@types/geojson": "^7946.0.10", - "d3-geo": "1.7.1" + "d3-geo": "1.7.1", + "tslib": "^2.6.2" } } diff --git a/packages/turf-buffer/types.ts b/packages/turf-buffer/types.ts deleted file mode 100644 index 8a6ff304a0..0000000000 --- a/packages/turf-buffer/types.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { - point, - lineString, - polygon, - multiPoint, - multiLineString, - multiPolygon, - featureCollection, - geometryCollection, -} from "@turf/helpers"; -import { Point, LineString } from "geojson"; -import { buffer } from "./index.js"; - -// Standard Geometry -const pt = point([100, 0]); -const line = lineString([ - [100, 0], - [50, 0], -]); -const poly = polygon([ - [ - [100, 0], - [50, 0], - [0, 50], - [100, 0], - ], -]); - -buffer(pt, 5); -buffer(line, 5); -buffer(poly, 5); -buffer(pt, 5, { units: "miles" }); -buffer(pt, 10, { units: "meters", steps: 64 }); - -// Multi Geometry -const multiPt = multiPoint([ - [100, 0], - [0, 100], -]); -const multiLine = multiLineString([ - [ - [100, 0], - [50, 0], - ], - [ - [100, 0], - [50, 0], - ], -]); -const multiPoly = multiPolygon([ - [ - [ - [100, 0], - [50, 0], - [0, 50], - [100, 0], - ], - ], - [ - [ - [100, 0], - [50, 0], - [0, 50], - [100, 0], - ], - ], -]); - -buffer(multiPt, 5); -buffer(multiLine, 5); -buffer(multiPoly, 5); - -// Collections -const fc = featureCollection([pt, line]); -const gc = geometryCollection([pt.geometry, line.geometry]); - -buffer(fc, 5); -buffer(gc, 5); - -// Mixed Collections -const fcMixed = featureCollection([pt, line, multiPt, multiLine]); -const gcMixed = geometryCollection([ - pt.geometry, - line.geometry, - multiPt.geometry, - multiLine.geometry, -]); - -buffer(fcMixed, 5); -buffer(gcMixed, 5); diff --git a/packages/turf-center-mean/package.json b/packages/turf-center-mean/package.json index 6fe4b8ac7d..7bd3652845 100644 --- a/packages/turf-center-mean/package.json +++ b/packages/turf-center-mean/package.json @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/center": "workspace:^", diff --git a/packages/turf-center-mean/types.ts b/packages/turf-center-mean/types.ts deleted file mode 100644 index 8c0d54ab02..0000000000 --- a/packages/turf-center-mean/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { lineString } from "@turf/helpers"; -import { centerMean } from "./index.js"; - -const line = lineString([ - [0, 0], - [10, 10], -]); - -centerMean(line); -centerMean(line, { properties: { foo: "bar" } }); -centerMean(line, { weight: "foo" }); diff --git a/packages/turf-center-median/package.json b/packages/turf-center-median/package.json index 4b92db29b2..06884a2e1a 100644 --- a/packages/turf-center-median/package.json +++ b/packages/turf-center-median/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/center": "workspace:^", diff --git a/packages/turf-center-of-mass/package.json b/packages/turf-center-of-mass/package.json index 58548a0298..c3bf5d8b37 100644 --- a/packages/turf-center-of-mass/package.json +++ b/packages/turf-center-of-mass/package.json @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-center-of-mass/types.ts b/packages/turf-center-of-mass/types.ts deleted file mode 100644 index 773280c0b7..0000000000 --- a/packages/turf-center-of-mass/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { lineString } from "@turf/helpers"; -import { centerOfMass } from "./index.js"; - -const line = lineString([ - [0, 0], - [10, 10], -]); - -centerOfMass(line); -centerOfMass(line, { properties: { foo: "bar" } }); diff --git a/packages/turf-center/package.json b/packages/turf-center/package.json index c21303a23b..2cd135356c 100644 --- a/packages/turf-center/package.json +++ b/packages/turf-center/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-center/types.ts b/packages/turf-center/types.ts deleted file mode 100644 index 20e2e9a957..0000000000 --- a/packages/turf-center/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { lineString } from "@turf/helpers"; -import { center } from "./index.js"; - -const line = lineString([ - [0, 0], - [10, 10], -]); - -center(line); -center(line, { properties: { foo: "bar" } }); diff --git a/packages/turf-centroid/package.json b/packages/turf-centroid/package.json index 5ad62aa884..3c48e71580 100644 --- a/packages/turf-centroid/package.json +++ b/packages/turf-centroid/package.json @@ -49,7 +49,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-centroid/types.ts b/packages/turf-centroid/types.ts deleted file mode 100644 index 37700d53ca..0000000000 --- a/packages/turf-centroid/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { lineString } from "@turf/helpers"; -import { centroid } from "./index.js"; - -const line = lineString([ - [0, 0], - [10, 10], -]); - -centroid(line); -centroid(line, { properties: { foo: "bar" } }); diff --git a/packages/turf-circle/package.json b/packages/turf-circle/package.json index 86305350fc..a19b87553e 100644 --- a/packages/turf-circle/package.json +++ b/packages/turf-circle/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@placemarkio/check-geojson": "^0.1.12", diff --git a/packages/turf-circle/types.ts b/packages/turf-circle/types.ts deleted file mode 100644 index 453fb9ae7f..0000000000 --- a/packages/turf-circle/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { point } from "@turf/helpers"; -import { circle } from "./index.js"; - -const center = point([-75.343, 39.984]); -const units = "kilometers"; -const radius = 5; -const steps = 10; - -circle(center, radius); -circle(center, radius, { steps }); -circle(center, radius, { steps, units }); -circle([-75, 39], radius, { steps, units, properties: { foo: "bar" } }); diff --git a/packages/turf-clean-coords/package.json b/packages/turf-clean-coords/package.json index 4a95525a38..064c44c553 100644 --- a/packages/turf-clean-coords/package.json +++ b/packages/turf-clean-coords/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-clean-coords/types.ts b/packages/turf-clean-coords/types.ts deleted file mode 100644 index b9037fa586..0000000000 --- a/packages/turf-clean-coords/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { multiPoint } from "@turf/helpers"; -import { cleanCoords } from "./index.js"; - -// Fixtures -const multiPt = multiPoint([ - [0, 0], - [0, 0], - [2, 2], -]); - -// Feature -cleanCoords(multiPt).geometry; -cleanCoords(multiPt).properties; - -// Geometry -cleanCoords(multiPt.geometry).coordinates; -cleanCoords(multiPt.geometry).type; - -// Input mutation -cleanCoords(multiPt.geometry, { mutate: true }); diff --git a/packages/turf-clone/package.json b/packages/turf-clone/package.json index efc345f81e..616e8726a0 100644 --- a/packages/turf-clone/package.json +++ b/packages/turf-clone/package.json @@ -50,7 +50,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/meta": "workspace:^", diff --git a/packages/turf-clone/types.ts b/packages/turf-clone/types.ts deleted file mode 100644 index 07e9831a6c..0000000000 --- a/packages/turf-clone/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { Feature, LineString, Point } from "geojson"; -import { lineString, point } from "@turf/helpers"; -import { clone } from "./index.js"; - -const pt = point([0, 20]); -const ptCloned: Feature = clone(pt); - -const line = lineString([ - [0, 20], - [10, 10], -]).geometry; -const lineCloned: LineString = clone(line); diff --git a/packages/turf-clusters-dbscan/index.ts b/packages/turf-clusters-dbscan/index.ts index fa89f4e8b4..86bd05877e 100644 --- a/packages/turf-clusters-dbscan/index.ts +++ b/packages/turf-clusters-dbscan/index.ts @@ -2,7 +2,7 @@ import { GeoJsonProperties, FeatureCollection, Point } from "geojson"; import { clone } from "@turf/clone"; import { distance } from "@turf/distance"; import { degreesToRadians, lengthToDegrees, Units } from "@turf/helpers"; -import { rbush as RBush } from "./lib/rbush-export.js"; +import rbush from "rbush"; type Dbscan = "core" | "edge" | "noise"; type DbscanProps = GeoJsonProperties & { @@ -67,7 +67,7 @@ function clustersDbscan( const latDistanceInDegrees = lengthToDegrees(maxDistance, options.units); // Create a spatial index - var tree = new RBush(points.features.length); + var tree = new rbush(points.features.length); // Keeps track of whether a point has been visited or not. var visited = points.features.map((_) => false); diff --git a/packages/turf-clusters-dbscan/lib/rbush-export.ts b/packages/turf-clusters-dbscan/lib/rbush-export.ts deleted file mode 100644 index 49463b8ab5..0000000000 --- a/packages/turf-clusters-dbscan/lib/rbush-export.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Get around problems with moduleResolution node16 and some older libraries. -// Manifests as "This expression is not callable ... has no call signatures" -// https://stackoverflow.com/a/74709714 - -import lib from "rbush"; - -export const rbush = lib as unknown as typeof lib.default; diff --git a/packages/turf-clusters-dbscan/package.json b/packages/turf-clusters-dbscan/package.json index 3bc8defc98..dbaef6c303 100644 --- a/packages/turf-clusters-dbscan/package.json +++ b/packages/turf-clusters-dbscan/package.json @@ -57,7 +57,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/centroid": "workspace:^", diff --git a/packages/turf-clusters-dbscan/types.ts b/packages/turf-clusters-dbscan/types.ts deleted file mode 100644 index 0433d16097..0000000000 --- a/packages/turf-clusters-dbscan/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { featureCollection, point } from "@turf/helpers"; -import { clustersDbscan } from "./index.js"; - -// Fixtures -const points = featureCollection([point([0, 0]), point([2, 2])]); - -// Default -const maxDistance = 5; -const clustered = clustersDbscan(points, maxDistance); - -// Enforce strict properties when using the dbscan property -const output = clustersDbscan(points, maxDistance); -let { dbscan, cluster } = output.features[0].properties; -dbscan = "edge"; -dbscan = "core"; -dbscan = "noise"; -// dbscan = 'foo' //= [ts] Type '"foo"' is not assignable to type '"core" | "edge" | "noise"'. -clustersDbscan(output, maxDistance); - -// Options -const minPoints = 3; -const units = "miles"; -clustersDbscan(points, maxDistance); -clustersDbscan(points, maxDistance, { units }); -clustersDbscan(points, maxDistance, { units, minPoints }); - -// Custom Properties -clustered.features[0].properties.cluster; -clustered.features[0].properties.dbscan; -clustered.features[0].properties.foo; diff --git a/packages/turf-clusters-kmeans/package.json b/packages/turf-clusters-kmeans/package.json index e3f2b1791c..04b89e809b 100644 --- a/packages/turf-clusters-kmeans/package.json +++ b/packages/turf-clusters-kmeans/package.json @@ -56,7 +56,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/centroid": "workspace:^", diff --git a/packages/turf-clusters-kmeans/types.ts b/packages/turf-clusters-kmeans/types.ts deleted file mode 100644 index 6e9a779171..0000000000 --- a/packages/turf-clusters-kmeans/types.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { featureCollection, point } from "@turf/helpers"; -import { clustersKmeans } from "./index.js"; - -// Fixtures -const points = featureCollection([point([0, 0]), point([2, 2])]); - -// Default -const numberOfClusters = 5; -const clustered = clustersKmeans(points, { numberOfClusters }); -let { cluster, centroid } = clustered.features[0].properties; -cluster = 2; -centroid = [-110, 85]; -// cluster = 'foo' // Type Error - Type '"foo"' is not assignable to type 'number'. -// centroid = 'foo' // Type Error - Type '"foo"' is not assignable to type '[number, number]'. - -// Properties option -clustersKmeans(points); -clustersKmeans(points, { numberOfClusters }); -clustersKmeans(points, { numberOfClusters, mutate: true }); - -// Custom Properties -clustered.features[0].properties.centroid; -clustered.features[0].properties.cluster; -clustered.features[0].properties.foo; diff --git a/packages/turf-clusters/package.json b/packages/turf-clusters/package.json index 0f461bdb79..f9ebdd41c6 100644 --- a/packages/turf-clusters/package.json +++ b/packages/turf-clusters/package.json @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-clusters/types.ts b/packages/turf-clusters/types.ts deleted file mode 100644 index 3af8b77f30..0000000000 --- a/packages/turf-clusters/types.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { Point } from "geojson"; -import * as clusters from "./index.js"; -import { featureCollection, point } from "@turf/helpers"; -import { getCluster, clusterEach, clusterReduce } from "./index.js"; - -/** - * Fixtures - */ -const geojson = featureCollection< - Point, - { cluster?: number; 0?: string; bar?: string } ->([ - point([0, 0], { cluster: 0 }), - point([2, 4], { cluster: 1 }), - point([3, 6], { cluster: 1 }), - point([3, 6], { 0: "foo" }), - point([3, 6], { bar: "foo" }), -]); - -/** - * Get Cluster - */ -clusters.getCluster(geojson, { cluster: 1 }); -getCluster(geojson, { cluster: 1 }); -getCluster(geojson, { 0: "foo" }); -getCluster(geojson, { bar: "foo" }); -getCluster(geojson, "cluster"); -getCluster(geojson, ["cluster", "bar"]); -getCluster(geojson, 0); - -/** - * ClusterEach - */ -clusters.clusterEach(geojson, "cluster", () => { - /* no-op */ -}); -clusterEach(geojson, "cluster", (cluster, clusterValue, currentIndex) => { - //= cluster - //= clusterValue - //= currentIndex -}); -// Calculate the total number of clusters -let total = 0; -clusterEach(geojson, "cluster", () => { - total++; -}); - -// Create an Array of all the values retrieved from the 'cluster' property -const values: number[] = []; -clusterEach(geojson, "cluster", (cluster, clusterValue: number) => { - values.push(clusterValue); -}); - -/** - * ClusterReduce - */ -const initialValue = 0; -clusterReduce(geojson, "cluster", () => { - /* no-op */ -}); -clusterReduce( - geojson, - "cluster", - (previousValue, cluster, clusterValue, currentIndex) => { - //= previousValue - //= cluster - //= clusterValue - //= currentIndex - }, - initialValue -); - -// Calculate the total number of clusters -const totalReduce = clusterReduce( - geojson, - "cluster", - function (previousValue) { - return previousValue++; - }, - 0 -); - -// Create an Array of all the values retrieved from the 'cluster' property -const valuesReduce = clusterReduce( - geojson, - "cluster", - function (previousValue, cluster, clusterValue) { - return previousValue.concat(clusterValue); - }, - [] -); - -/** - * Custom Properties - */ -const customPoints = featureCollection([ - point([0, 0], { cluster: 0 }), - point([2, 4], { cluster: 1 }), - point([3, 6], { cluster: 1 }), -]); - -getCluster(customPoints, { cluster: 1 }).features[0].properties.cluster; -// getCluster(customPoints, {cluster: 1}).features[0].properties.foo // [ts] Property 'foo' does not exist on type '{ cluster: number; }'. - -clusterEach(customPoints, "cluster", (cluster) => { - cluster.features[0].properties.cluster; - // cluster.features[0].properties.foo // [ts] Property 'foo' does not exist on type '{ cluster: number; }'. -}); - -clusterReduce(customPoints, "cluster", (previousValue, cluster) => { - cluster.features[0].properties.cluster; - // cluster.features[0].properties.foo // [ts] Property 'foo' does not exist on type '{ cluster: number; }'. -}); diff --git a/packages/turf-collect/index.ts b/packages/turf-collect/index.ts index bde4e7c069..d8b713adab 100644 --- a/packages/turf-collect/index.ts +++ b/packages/turf-collect/index.ts @@ -1,7 +1,7 @@ import { FeatureCollection, Polygon, Point } from "geojson"; import { bbox as turfbbox } from "@turf/bbox"; import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon"; -import { rbush } from "./lib/rbush-export.js"; +import rbush from "rbush"; interface Entry { minX: number; diff --git a/packages/turf-collect/lib/rbush-export.ts b/packages/turf-collect/lib/rbush-export.ts deleted file mode 100644 index 49463b8ab5..0000000000 --- a/packages/turf-collect/lib/rbush-export.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Get around problems with moduleResolution node16 and some older libraries. -// Manifests as "This expression is not callable ... has no call signatures" -// https://stackoverflow.com/a/74709714 - -import lib from "rbush"; - -export const rbush = lib as unknown as typeof lib.default; diff --git a/packages/turf-collect/package.json b/packages/turf-collect/package.json index 54d08bc197..b8f8f33989 100644 --- a/packages/turf-collect/package.json +++ b/packages/turf-collect/package.json @@ -53,7 +53,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-combine/package.json b/packages/turf-combine/package.json index 605276e2dd..c5576dae40 100644 --- a/packages/turf-combine/package.json +++ b/packages/turf-combine/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-concave/package.json b/packages/turf-concave/package.json index 9583824c3c..a39cf8aa46 100644 --- a/packages/turf-concave/package.json +++ b/packages/turf-concave/package.json @@ -59,7 +59,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-convex/package.json b/packages/turf-convex/package.json index 2905b33f29..814db7258e 100644 --- a/packages/turf-convex/package.json +++ b/packages/turf-convex/package.json @@ -46,7 +46,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-destination/package.json b/packages/turf-destination/package.json index 155ecc5ce6..352c8e8ec2 100644 --- a/packages/turf-destination/package.json +++ b/packages/turf-destination/package.json @@ -50,7 +50,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-difference/package.json b/packages/turf-difference/package.json index 321ee633f2..4c7e7dfa94 100644 --- a/packages/turf-difference/package.json +++ b/packages/turf-difference/package.json @@ -46,7 +46,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-directional-mean/package.json b/packages/turf-directional-mean/package.json index 36e5552c58..a93b937370 100644 --- a/packages/turf-directional-mean/package.json +++ b/packages/turf-directional-mean/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-dissolve/package.json b/packages/turf-dissolve/package.json index 48e4c90c7e..1b848019bc 100644 --- a/packages/turf-dissolve/package.json +++ b/packages/turf-dissolve/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-distance-weight/package.json b/packages/turf-distance-weight/package.json index 7563e7854b..92f39285b6 100644 --- a/packages/turf-distance-weight/package.json +++ b/packages/turf-distance-weight/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-distance/package.json b/packages/turf-distance/package.json index fb15447ae1..58678d1182 100644 --- a/packages/turf-distance/package.json +++ b/packages/turf-distance/package.json @@ -48,7 +48,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-ellipse/package.json b/packages/turf-ellipse/package.json index eea2117419..738cc4bcaa 100644 --- a/packages/turf-ellipse/package.json +++ b/packages/turf-ellipse/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@placemarkio/check-geojson": "^0.1.12", diff --git a/packages/turf-envelope/package.json b/packages/turf-envelope/package.json index a886e7b910..8e0ba143c8 100644 --- a/packages/turf-envelope/package.json +++ b/packages/turf-envelope/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-explode/package.json b/packages/turf-explode/package.json index aaa87b435f..0d2dbac20c 100644 --- a/packages/turf-explode/package.json +++ b/packages/turf-explode/package.json @@ -48,7 +48,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-flatten/package.json b/packages/turf-flatten/package.json index bca313efa5..abdc44c438 100644 --- a/packages/turf-flatten/package.json +++ b/packages/turf-flatten/package.json @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-flatten/types.ts b/packages/turf-flatten/types.ts deleted file mode 100644 index 563b0945e8..0000000000 --- a/packages/turf-flatten/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { FeatureCollection, Point, LineString } from "geojson"; -import { - multiPoint, - multiLineString, - geometryCollection, - // Typescript types -} from "@turf/helpers"; -import { flatten } from "./index.js"; - -const multiPt = multiPoint([ - [0, 0], - [10, 10], -]); -const multiLine = multiLineString([ - [ - [20, 20], - [30, 30], - ], - [ - [0, 0], - [10, 10], - ], -]); - -let points: FeatureCollection = flatten(multiPt); -let lines: FeatureCollection = flatten(multiLine); -points = flatten(multiPt.geometry); -lines = flatten(multiLine.geometry); - -flatten(geometryCollection([multiPt.geometry, multiLine.geometry])); diff --git a/packages/turf-flip/package.json b/packages/turf-flip/package.json index e87727629a..bf802659e0 100644 --- a/packages/turf-flip/package.json +++ b/packages/turf-flip/package.json @@ -49,7 +49,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-flip/types.ts b/packages/turf-flip/types.ts deleted file mode 100644 index c4543fe9c6..0000000000 --- a/packages/turf-flip/types.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - featureCollection, - point, - lineString, - geometryCollection, -} from "@turf/helpers"; -import { flip } from "./index.js"; - -const pt = point([120.1234567, 40.1234567]); -const ptGeom = pt.geometry; -const line = lineString([ - [20, 80], - [50, 40], -]); -const lineGeom = line.geometry; -const points = featureCollection([pt]); -const lines = featureCollection([line]); -const geomCollection = geometryCollection([ptGeom, lineGeom]); - -flip(pt); -flip(ptGeom); -flip(line); -flip(lineGeom); -flip(lines); -flip(points); -flip(geomCollection, { mutate: true }); diff --git a/packages/turf-geojson-rbush/package.json b/packages/turf-geojson-rbush/package.json index 5d19ba7cdb..30585d17d6 100644 --- a/packages/turf-geojson-rbush/package.json +++ b/packages/turf-geojson-rbush/package.json @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", @@ -68,7 +68,7 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", - "typescript": "^5.2.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { @@ -76,6 +76,7 @@ "@turf/helpers": "workspace:^", "@turf/meta": "workspace:^", "@types/geojson": "^7946.0.10", - "rbush": "^3.0.1" + "rbush": "^3.0.1", + "tslib": "^2.6.2" } } diff --git a/packages/turf-geojson-rbush/types.ts b/packages/turf-geojson-rbush/types.ts deleted file mode 100644 index e094f03eed..0000000000 --- a/packages/turf-geojson-rbush/types.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { point, polygon, featureCollection } from "@turf/helpers"; -import { BBox, Point, Polygon } from "geojson"; -import { geojsonRbush as rbush } from "./index.js"; - -// Fixtures -const bbox: BBox = [-180, -90, 180, 90]; -const pt = point([0, 0]); -const points = featureCollection([pt, pt]); -const poly = polygon([ - [ - [0, 0], - [1, 1], - [1, 1], - [0, 0], - ], -]); -const polygons = featureCollection([poly, poly]); - -// Initialize GeoJSON RBush Tree -const tree = rbush(); - -// Load Tree with a FeatureCollection -tree.load(points); -tree.load(polygons); - -// Insert by Feature -tree.insert(pt); -tree.insert(poly); - -// Find All (returns FeatureCollection) -const all = tree.all(); - -// Search by Feature (returns FeatureCollection) -const search = tree.search(poly); - -// Collides by Feature (returns FeatureCollection) -const collides = tree.collides(poly); - -// Remove by Feature -tree.remove(pt); -tree.remove(poly); - -// BBox support -tree.search(bbox); -tree.collides(bbox); diff --git a/packages/turf-great-circle/package.json b/packages/turf-great-circle/package.json index d55d5e64ac..ff678534e1 100644 --- a/packages/turf-great-circle/package.json +++ b/packages/turf-great-circle/package.json @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", @@ -67,11 +67,13 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { "@turf/helpers": "workspace:^", "@turf/invariant": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-great-circle/types.ts b/packages/turf-great-circle/types.ts deleted file mode 100644 index c12a7901c8..0000000000 --- a/packages/turf-great-circle/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { point } from "@turf/helpers"; -import { greatCircle } from "./index.js"; - -const pt1 = point([0, 0]); -const pt2 = point([60, 0]); -greatCircle(pt1, pt2); -greatCircle(pt1.geometry, pt2.geometry); -greatCircle(pt1.geometry.coordinates, pt2.geometry.coordinates); -greatCircle(pt1, pt2, { properties: { name: "Seattle to DC" } }); -greatCircle(pt1, pt2, { npoints: 10 }); -greatCircle(pt1, pt2, { offset: 100, npoints: 10 }); diff --git a/packages/turf-helpers/package.json b/packages/turf-helpers/package.json index 87a45f63cb..75b4a73a64 100644 --- a/packages/turf-helpers/package.json +++ b/packages/turf-helpers/package.json @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-helpers/types.ts b/packages/turf-helpers/types.ts deleted file mode 100644 index f414108041..0000000000 --- a/packages/turf-helpers/types.ts +++ /dev/null @@ -1,213 +0,0 @@ -import { BBox, GeometryCollection, LineString, Polygon, Point } from "geojson"; -import { - feature, - featureCollection, - geometry, - geometryCollection, - isNumber, - isObject, - lengthToDegrees, - lengthToRadians, - lineString, - multiLineString, - multiPoint, - multiPolygon, - // Typescript types - point, - polygon, - radiansToLength, -} from "./index.js"; - -// Fixtures -const bbox: BBox = [-180, -90, 180, 90]; -const properties = { foo: "bar" }; -const pt = point([0, 1]); -const line = lineString([ - [0, 1], - [2, 3], -]); -const poly = polygon([ - [ - [0, 1], - [0, 0], - [2, 3], - [0, 1], - ], -]); -const feat = feature({ coordinates: [1, 0], type: "Point" }); -const multiPt = multiPoint([ - [0, 1], - [2, 3], - [0, 1], -]); -const multiLine = multiLineString([ - [ - [0, 1], - [2, 3], - [0, 1], - ], -]); -const multiPoly = multiPolygon([ - [ - [ - [0, 1], - [0, 0], - [2, 3], - [0, 1], - ], - ], -]); - -// radiansToLength & lengthToRadians -radiansToLength(5); -lengthToRadians(10); -lengthToDegrees(45); - -// default import & import * as -point([0, 1]); -lineString([ - [0, 1], - [2, 3], -]); -polygon([ - [ - [0, 1], - [0, 0], - [2, 3], - [0, 1], - ], -]); -feature({ coordinates: [1, 0], type: "Point" }); -feature(null); -multiPoint([ - [0, 1], - [2, 3], - [0, 1], -]); -multiLineString([ - [ - [0, 1], - [2, 3], - [0, 1], - ], -]); -multiPolygon([ - [ - [ - [0, 1], - [0, 0], - [2, 3], - [0, 1], - ], - ], -]); - -// Mixed collection is defiend as FeatureCollection -const mixed = featureCollection([pt, poly]); -mixed.features.push(pt); -mixed.features.push(line); -mixed.features.push(poly); - -// Blank collection is defined as FeatureCollection -const blank = featureCollection([]); -blank.features.push(pt); -blank.features.push(line); -blank.features.push(poly); - -// Collection with only Points -const points = featureCollection([]); -points.features.push(pt); -// points.features.push(line) -// Argument of type 'Feature' is not assignable to parameter of type 'Feature'. - -// Collection with only LineStrings -const lines = featureCollection([line]); -lines.features.push(line); -// lines.features.push(pt) -// Argument of type 'Feature' is not assignable to parameter of type 'Feature'. - -// Collection with only Polygons -const polygons = featureCollection([]); -polygons.features.push(poly); - -// bbox & id -point(pt.geometry.coordinates, properties, { bbox, id: 1 }); -lineString(line.geometry.coordinates, properties, { bbox, id: 1 }); -polygon(poly.geometry.coordinates, properties, { bbox, id: 1 }); -multiPoint(multiPt.geometry.coordinates, properties, { bbox, id: 1 }); -multiLineString(multiLine.geometry.coordinates, properties, { bbox, id: 1 }); -multiPolygon(multiPoly.geometry.coordinates, properties, { bbox, id: 1 }); -geometryCollection([pt.geometry], properties, { bbox, id: 1 }); - -// properties -point(pt.geometry.coordinates, { foo: "bar" }); -point(pt.geometry.coordinates, { 1: 2 }); -point(pt.geometry.coordinates, { 1: { foo: "bar" } }); - -// isNumber -- true -isNumber(123); -isNumber(1.23); -isNumber(-1.23); -isNumber(-123); -isNumber("123"); -isNumber(+"123"); -isNumber("1e10000"); -isNumber(1e100); -isNumber(Infinity); -isNumber(-Infinity); - -// isNumber -- false -isNumber(+"ciao"); -isNumber("foo"); -isNumber("10px"); -isNumber(NaN); -isNumber(undefined); -isNumber(null); -isNumber({ a: 1 }); -isNumber({}); -isNumber([1, 2, 3]); -isNumber([]); -isNumber(isNumber); - -// isObject -- true -isObject({ a: 1 }); -isObject({}); -isObject(point([0, 1])); - -// isObject -- false -isObject(123); -isObject(Infinity); -isObject(-123); -isObject("foo"); -isObject(NaN); -isObject(undefined); -isObject(null); -isObject([1, 2, 3]); -isObject([]); -isObject(isNumber); - -// Geometry -const ptGeom = geometry("Point", pt.geometry.coordinates); -const lineGeom = geometry("LineString", line.geometry.coordinates); -const polyGeom = geometry("Polygon", poly.geometry.coordinates); -const multiPtGeom = geometry("MultiPoint", multiPt.geometry.coordinates); -const multiLineGeom = geometry( - "MultiLineString", - multiLine.geometry.coordinates -); -const multiPolyGeom = geometry("MultiPolygon", multiPoly.geometry.coordinates); - -// Custom Properties -const customPt = point([10, 50], { foo: "bar" }); - -// Handle GeometryCollection & Feature.GeometryCollection -const geomCollection = geometryCollection([pt.geometry, line.geometry]); -const p1 = geomCollection.geometry.geometries[0]; -const l1 = geomCollection.geometry.geometries[0]; - -const mixedGeomCollection = featureCollection([ - pt, - geomCollection, -]); -const fc = featureCollection([pt, line]); -const featureGeomCollection = feature(geomCollection.geometry); diff --git a/packages/turf-hex-grid/package.json b/packages/turf-hex-grid/package.json index 97345508e5..85a3ef0550 100644 --- a/packages/turf-hex-grid/package.json +++ b/packages/turf-hex-grid/package.json @@ -59,7 +59,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-hex-grid/types.ts b/packages/turf-hex-grid/types.ts deleted file mode 100644 index 1b07967130..0000000000 --- a/packages/turf-hex-grid/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { BBox } from "geojson"; -import { hexGrid } from "./index.js"; - -// prettier-ignore -const bbox: BBox = [ - -96.6357421875, - 31.12819929911196, - -84.9462890625, - 40.58058466412764, -]; - -hexGrid(bbox, 50); -hexGrid(bbox, 50, { units: "miles" }); -hexGrid(bbox, 50, { units: "miles", triangles: true }); - -// Access Custom Properties -const foo = hexGrid(bbox, 50, { - units: "miles", - triangles: true, - properties: { foo: "bar" }, -}); -foo.features[0].properties.foo; -// foo.features[0].properties.bar // => [ts] Property 'bar' does not exist on type '{ foo: string; }'. diff --git a/packages/turf-interpolate/package.json b/packages/turf-interpolate/package.json index ecbaa390d7..faf952e990 100644 --- a/packages/turf-interpolate/package.json +++ b/packages/turf-interpolate/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", @@ -64,6 +64,7 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { @@ -78,6 +79,7 @@ "@turf/point-grid": "workspace:^", "@turf/square-grid": "workspace:^", "@turf/triangle-grid": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-interpolate/types.ts b/packages/turf-interpolate/types.ts deleted file mode 100644 index 61281353d5..0000000000 --- a/packages/turf-interpolate/types.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { point, featureCollection } from "@turf/helpers"; -import { interpolate } from "./index.js"; - -const cellSize = 1; -const property = "pressure"; -const gridType = "square"; -const weight = 0.5; -const units = "miles"; -const points = featureCollection([ - point([1, 2]), - point([12, 13]), - point([23, 22]), -]); - -const grid = interpolate(points, cellSize, { - gridType, - property, - units, - weight, -}); -grid.features[0].properties?.pressure; - -// Optional properties -interpolate(points, cellSize, { gridType, property, units }); -interpolate(points, cellSize, { gridType, property }); -interpolate(points, cellSize, { gridType }); -interpolate(points, cellSize, { gridType: "point" }); diff --git a/packages/turf-intersect/package.json b/packages/turf-intersect/package.json index 6c2a042fde..12aef52133 100644 --- a/packages/turf-intersect/package.json +++ b/packages/turf-intersect/package.json @@ -48,7 +48,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-intersect/types.ts b/packages/turf-intersect/types.ts deleted file mode 100644 index 588c1800f1..0000000000 --- a/packages/turf-intersect/types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { featureCollection, polygon } from "@turf/helpers"; -import { intersect } from "./index.js"; - -const poly1 = polygon([ - [ - [0, 0], - [1, 1], - [3, 0], - [0, 0], - ], -]); -const poly2 = polygon([ - [ - [10, 10], - [21, 21], - [0, 4], - [10, 10], - ], -]); - -const match = intersect(featureCollection([poly1, poly2])); - -if (match === null) console.log("foo"); - -const foo = intersect(featureCollection([poly1, poly2])) || "bar"; diff --git a/packages/turf-invariant/package.json b/packages/turf-invariant/package.json index 642eacd2b5..ecce4f6e51 100644 --- a/packages/turf-invariant/package.json +++ b/packages/turf-invariant/package.json @@ -52,7 +52,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-invariant/types.ts b/packages/turf-invariant/types.ts deleted file mode 100644 index 4b019b95f9..0000000000 --- a/packages/turf-invariant/types.ts +++ /dev/null @@ -1,77 +0,0 @@ -import * as helpers from "@turf/helpers"; -import { - GeometryCollection, - LineString, - Point, - Polygon, - Position, -} from "geojson"; -import * as invariant from "./index.js"; - -/** - * Fixtures - */ -const pt = helpers.point([0, 0]); -const line = helpers.lineString([ - [0, 0], - [1, 1], -]); -const poly = helpers.polygon([ - [ - [0, 0], - [1, 1], - [2, 2], - [0, 0], - ], -]); -const gc = helpers.geometryCollection([ - pt.geometry, - line.geometry, - poly.geometry, -]); -const fc = helpers.featureCollection([ - pt, - line, - poly, -]); - -/** - * invariant.getGeom - */ -// invariant.getGeom(fc); // Argument of type 'FeatureCollection' is not assignable to parameter of type -const gcGeom: GeometryCollection = invariant.getGeom(gc); -const pointGeom: Point = invariant.getGeom(pt); -const lineGeom: LineString = invariant.getGeom(line); -const polyGeom: Polygon = invariant.getGeom(poly); - -/** - * invariant.getType - */ -const type = invariant.getType(pt); - -/** - * getCoord - */ -invariant.getCoord(pt); -invariant.getCoord(pt.geometry); -invariant.getCoord(pt.geometry.coordinates); -let coordZ = [10, 30, 2000]; -coordZ = invariant.getCoord(coordZ); - -/** - * getCoords - */ -invariant.getCoords(pt.geometry)[0].toFixed(); -invariant.getCoords(pt.geometry.coordinates)[0].toFixed(); -invariant.getCoords(pt)[0].toFixed(); -invariant.getCoords(line.geometry)[0][0].toFixed(); -invariant.getCoords(line.geometry.coordinates)[0][0].toFixed(); -invariant.getCoords(line)[0][0].toFixed(); -invariant.getCoords(poly)[0][0][0].toFixed(); -invariant.getCoords(poly.geometry)[0][0][0].toFixed(); -invariant.getCoords(poly.geometry.coordinates)[0][0][0].toFixed(); -const lineCoords: Position[] = [ - [10, 30], - [40, 40], -]; -invariant.getCoords(lineCoords)[0][0].toFixed(); diff --git a/packages/turf-isobands/package.json b/packages/turf-isobands/package.json index 948eec4dec..46e25e7248 100644 --- a/packages/turf-isobands/package.json +++ b/packages/turf-isobands/package.json @@ -54,7 +54,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/envelope": "workspace:^", diff --git a/packages/turf-isobands/tsconfig.json b/packages/turf-isobands/tsconfig.json index 563bf86442..dec1a231df 100644 --- a/packages/turf-isobands/tsconfig.json +++ b/packages/turf-isobands/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "../../tsconfig.shared.json" + "extends": "../../tsconfig.shared.json", + "files": ["index.ts", "marchingsquares.d.ts"] } diff --git a/packages/turf-isolines/index.ts b/packages/turf-isolines/index.ts index bade82833a..248732a175 100644 --- a/packages/turf-isolines/index.ts +++ b/packages/turf-isolines/index.ts @@ -2,7 +2,6 @@ import { bbox } from "@turf/bbox"; import { coordEach } from "@turf/meta"; import { collectionOf } from "@turf/invariant"; import { multiLineString, featureCollection, isObject } from "@turf/helpers"; -// @ts-expect-error Legacy JS library with no types defined import { isoContours } from "marchingsquares"; import { gridToMatrix } from "./lib/grid-to-matrix.js"; import { diff --git a/packages/turf-isolines/marchingsquares.d.ts b/packages/turf-isolines/marchingsquares.d.ts new file mode 100644 index 0000000000..5e3233864f --- /dev/null +++ b/packages/turf-isolines/marchingsquares.d.ts @@ -0,0 +1 @@ +declare module "marchingsquares"; diff --git a/packages/turf-isolines/package.json b/packages/turf-isolines/package.json index 84d88940d4..4a32283974 100644 --- a/packages/turf-isolines/package.json +++ b/packages/turf-isolines/package.json @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/envelope": "workspace:^", diff --git a/packages/turf-isolines/tsconfig.json b/packages/turf-isolines/tsconfig.json index 563bf86442..dec1a231df 100644 --- a/packages/turf-isolines/tsconfig.json +++ b/packages/turf-isolines/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "../../tsconfig.shared.json" + "extends": "../../tsconfig.shared.json", + "files": ["index.ts", "marchingsquares.d.ts"] } diff --git a/packages/turf-isolines/types.ts b/packages/turf-isolines/types.ts deleted file mode 100644 index 94275d8c23..0000000000 --- a/packages/turf-isolines/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { randomPoint } from "@turf/random"; -import { isolines } from "./index.js"; - -const points = randomPoint(100, { - bbox: [0, 30, 20, 50], -}); -for (let i = 0; i < points.features.length; i++) { - points.features[i].properties.z = Math.random() * 10; -} -const breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; -const lines = isolines(points, breaks, { zProperty: "temperature" }); -const properties = { apply: "all" }; - -// Properties option -isolines(points, breaks, { - zProperty: "temperature", - commonProperties: properties, -}); -isolines(points, breaks, { - zProperty: "temperature", - commonProperties: properties, - breaksProperties: [{ name: "break1" }, { name: "break2" }], -}); diff --git a/packages/turf-kinks/lib/sweepline-intersections-export.ts b/packages/turf-kinks/lib/sweepline-intersections-export.ts deleted file mode 100644 index 2d10f64b69..0000000000 --- a/packages/turf-kinks/lib/sweepline-intersections-export.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Get around problems with moduleResolution node16 and some older libraries. -// Manifests as "This expression is not callable ... has no call signatures" -// https://stackoverflow.com/a/74709714 - -import lib from "sweepline-intersections"; - -export const sweeplineIntersections = lib as unknown as typeof lib.default; diff --git a/packages/turf-kinks/package.json b/packages/turf-kinks/package.json index 575c8a33b5..08a4f3ee56 100644 --- a/packages/turf-kinks/package.json +++ b/packages/turf-kinks/package.json @@ -48,7 +48,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/meta": "workspace:^", diff --git a/packages/turf-kinks/types.ts b/packages/turf-kinks/types.ts deleted file mode 100644 index 105060ec0f..0000000000 --- a/packages/turf-kinks/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { polygon } from "@turf/helpers"; -import { kinks } from "./index.js"; - -const hourglass = polygon([ - [ - [-50, 5], - [-40, -10], - [-50, -10], - [-40, 5], - [-50, 5], - ], -]); -kinks(hourglass); diff --git a/packages/turf-length/package.json b/packages/turf-length/package.json index 954b5186cc..dc5aa82979 100644 --- a/packages/turf-length/package.json +++ b/packages/turf-length/package.json @@ -54,7 +54,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-line-arc/package.json b/packages/turf-line-arc/package.json index cb86fa3ef7..756bc57ae6 100644 --- a/packages/turf-line-arc/package.json +++ b/packages/turf-line-arc/package.json @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-line-arc/types.ts b/packages/turf-line-arc/types.ts deleted file mode 100644 index 8a82bb3473..0000000000 --- a/packages/turf-line-arc/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { point } from "@turf/helpers"; -import { lineArc } from "./index.js"; - -const center = point([-75.343, 39.984]); -const bearing1 = 10; -const bearing2 = -30; -const radius = 5; -const steps = 10; -const units = "miles"; - -lineArc(center, radius, bearing1, bearing2); -lineArc(center, radius, bearing1, bearing2, { steps }); -lineArc(center, radius, bearing1, bearing2, { steps, units }); diff --git a/packages/turf-line-chunk/package.json b/packages/turf-line-chunk/package.json index 983a4d0875..b6df22437e 100644 --- a/packages/turf-line-chunk/package.json +++ b/packages/turf-line-chunk/package.json @@ -56,7 +56,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", @@ -68,6 +68,7 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { @@ -75,6 +76,7 @@ "@turf/length": "workspace:^", "@turf/line-slice-along": "workspace:^", "@turf/meta": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-line-chunk/types.ts b/packages/turf-line-chunk/types.ts deleted file mode 100644 index fbd45b54aa..0000000000 --- a/packages/turf-line-chunk/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - lineString, - geometryCollection, - featureCollection, -} from "@turf/helpers"; -import { lineChunk } from "./index.js"; - -const line = lineString([ - [0, 0], - [1, 1], - [2, 2], -]); -const collection = featureCollection([line]); -const geomCollection = geometryCollection([line.geometry]); - -lineChunk(line, 2); -lineChunk(line, 2, { units: "kilometers" }); -lineChunk(line.geometry, 2); -lineChunk(collection, 2); -lineChunk(geomCollection, 2); diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index e4c83d30ed..9538fd022e 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -9,7 +9,7 @@ import { Polygon, } from "geojson"; import type { Intersection } from "sweepline-intersections"; -import { sweeplineIntersections as findIntersections } from "./lib/sweepline-intersections-export.js"; +import sweeplineIntersections from "sweepline-intersections"; /** * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s). @@ -66,7 +66,7 @@ function lineIntersect< features.push(feature(line2)); } - const intersections = findIntersections( + const intersections = sweeplineIntersections( featureCollection(features), ignoreSelfIntersections ); diff --git a/packages/turf-line-intersect/lib/sweepline-intersections-export.ts b/packages/turf-line-intersect/lib/sweepline-intersections-export.ts deleted file mode 100644 index 2d10f64b69..0000000000 --- a/packages/turf-line-intersect/lib/sweepline-intersections-export.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Get around problems with moduleResolution node16 and some older libraries. -// Manifests as "This expression is not callable ... has no call signatures" -// https://stackoverflow.com/a/74709714 - -import lib from "sweepline-intersections"; - -export const sweeplineIntersections = lib as unknown as typeof lib.default; diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index a7f3e1482b..175ccb7684 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -53,7 +53,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-line-offset/package.json b/packages/turf-line-offset/package.json index 34c28e4aa5..70a12820da 100644 --- a/packages/turf-line-offset/package.json +++ b/packages/turf-line-offset/package.json @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", @@ -66,12 +66,14 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { "@turf/helpers": "workspace:^", "@turf/invariant": "workspace:^", "@turf/meta": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-line-offset/types.ts b/packages/turf-line-offset/types.ts deleted file mode 100644 index 43789bcaa3..0000000000 --- a/packages/turf-line-offset/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { lineOffset } from "./index.js"; -import { lineString, multiLineString } from "@turf/helpers"; - -const line = lineString([ - [0, 0], - [10, 10], -]); -const multiLine = multiLineString([ - [ - [0, 0], - [10, 10], - ], - [ - [5, 5], - [15, 15], - ], -]); - -lineOffset(line, 50); -lineOffset(line.geometry, 50); -lineOffset(multiLine, 50); -lineOffset(multiLine.geometry, 50); -lineOffset(line, 50, { units: "miles" }); diff --git a/packages/turf-line-overlap/package.json b/packages/turf-line-overlap/package.json index ace935b7c8..9dbf677ea0 100644 --- a/packages/turf-line-overlap/package.json +++ b/packages/turf-line-overlap/package.json @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-line-overlap/types.ts b/packages/turf-line-overlap/types.ts deleted file mode 100644 index 9b1f420234..0000000000 --- a/packages/turf-line-overlap/types.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { - lineString, - multiLineString, - polygon, - multiPolygon, -} from "@turf/helpers"; -import { lineOverlap } from "./index.js"; - -const line = lineString([ - [0, 0], - [10, 10], -]); -const multiLine = multiLineString([ - [ - [0, 0], - [10, 10], - ], - [ - [30, 30], - [50, 50], - ], -]); -const poly = polygon([ - [ - [0, 0], - [10, 10], - [15, 15], - [0, 0], - ], -]); -const multiPoly = multiPolygon([ - [ - [ - [0, 0], - [10, 10], - [15, 15], - [0, 0], - ], - ], - [ - [ - [5, 5], - [30, 30], - [45, 45], - [5, 5], - ], - ], -]); - -lineOverlap(line, poly); -lineOverlap(line, line); -lineOverlap(multiPoly, line); -lineOverlap(multiPoly, multiLine); -lineOverlap(multiPoly, multiLine, { tolerance: 5 }); diff --git a/packages/turf-line-segment/package.json b/packages/turf-line-segment/package.json index be0b3bb813..d38be61df8 100644 --- a/packages/turf-line-segment/package.json +++ b/packages/turf-line-segment/package.json @@ -47,7 +47,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-line-slice-along/package.json b/packages/turf-line-slice-along/package.json index 3a7489e82d..07d2ba7fa0 100644 --- a/packages/turf-line-slice-along/package.json +++ b/packages/turf-line-slice-along/package.json @@ -47,7 +47,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/along": "workspace:^", @@ -59,13 +60,15 @@ "npm-run-all": "^4.1.5", "tape": "^5.7.2", "tsup": "^8.0.1", - "tsx": "^4.6.2" + "tsx": "^4.6.2", + "typescript": "^5.5.4" }, "dependencies": { "@turf/bearing": "workspace:^", "@turf/destination": "workspace:^", "@turf/distance": "workspace:^", "@turf/helpers": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-line-slice/package.json b/packages/turf-line-slice/package.json index f2c94cc197..94c268cd7d 100644 --- a/packages/turf-line-slice/package.json +++ b/packages/turf-line-slice/package.json @@ -51,7 +51,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", @@ -63,12 +64,14 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { "@turf/helpers": "workspace:^", "@turf/invariant": "workspace:^", "@turf/nearest-point-on-line": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-line-split/package.json b/packages/turf-line-split/package.json index f3b77ef585..517b55b9ed 100644 --- a/packages/turf-line-split/package.json +++ b/packages/turf-line-split/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", @@ -63,6 +64,7 @@ "tape": "^5.7.2", "tsup": "^8.0.1", "tsx": "^4.6.2", + "typescript": "^5.5.4", "write-json-file": "^5.0.0" }, "dependencies": { @@ -76,6 +78,7 @@ "@turf/nearest-point-on-line": "workspace:^", "@turf/square": "workspace:^", "@turf/truncate": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-line-to-polygon/README.md b/packages/turf-line-to-polygon/README.md index 93e53f3a13..a731b4f439 100644 --- a/packages/turf-line-to-polygon/README.md +++ b/packages/turf-line-to-polygon/README.md @@ -8,13 +8,12 @@ Converts (Multi)LineString(s) to Polygon(s). ### Parameters -* `lines` **([FeatureCollection][1] | [Feature][2]<([LineString][3] | [MultiLineString][4])>)** Features to convert -* `options` **[Object][5]** Optional parameters (optional, default `{}`) +* `options` **[Object][1]** Optional parameters (optional, default `{}`) - * `options.properties` **[Object][5]** translates GeoJSON properties to Feature (optional, default `{}`) - * `options.autoComplete` **[boolean][6]** auto complete linestrings (matches first & last coordinates) (optional, default `true`) - * `options.orderCoords` **[boolean][6]** sorts linestrings to place outer ring at the first position of the coordinates (optional, default `true`) - * `options.mutate` **[boolean][6]** mutate the original linestring using autoComplete (matches first & last coordinates) (optional, default `false`) + * `options.properties` **[Object][1]** translates GeoJSON properties to Feature (optional, default `{}`) + * `options.autoComplete` **[boolean][2]** auto complete linestrings (matches first & last coordinates) (optional, default `true`) + * `options.orderCoords` **[boolean][2]** sorts linestrings to place outer ring at the first position of the coordinates (optional, default `true`) + * `options.mutate` **[boolean][2]** mutate the original linestring using autoComplete (matches first & last coordinates) (optional, default `false`) ### Examples @@ -27,23 +26,17 @@ var polygon = turf.lineToPolygon(line); var addToMap = [polygon]; ``` -Returns **[Feature][2]<([Polygon][7] | [MultiPolygon][8])>** converted to Polygons +Returns **[Feature][3]<([Polygon][4] | [MultiPolygon][5])>** converted to Polygons -[1]: https://tools.ietf.org/html/rfc7946#section-3.3 +[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object -[2]: https://tools.ietf.org/html/rfc7946#section-3.2 +[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean -[3]: https://tools.ietf.org/html/rfc7946#section-3.1.4 +[3]: https://tools.ietf.org/html/rfc7946#section-3.2 -[4]: https://tools.ietf.org/html/rfc7946#section-3.1.5 +[4]: https://tools.ietf.org/html/rfc7946#section-3.1.6 -[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object - -[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean - -[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6 - -[8]: https://tools.ietf.org/html/rfc7946#section-3.1.7 +[5]: https://tools.ietf.org/html/rfc7946#section-3.1.7 diff --git a/packages/turf-line-to-polygon/index.ts b/packages/turf-line-to-polygon/index.ts index 78fb031417..92a4a7e529 100644 --- a/packages/turf-line-to-polygon/index.ts +++ b/packages/turf-line-to-polygon/index.ts @@ -6,6 +6,8 @@ import { GeoJsonProperties, BBox, Position, + Polygon, + MultiPolygon, } from "geojson"; import { bbox as turfBBox } from "@turf/bbox"; import { getCoords, getGeom } from "@turf/invariant"; @@ -16,7 +18,7 @@ import { clone } from "@turf/clone"; * Converts (Multi)LineString(s) to Polygon(s). * * @name lineToPolygon - * @param {FeatureCollection|Feature} lines Features to convert + * @param {FeatureCollection|Feature|} lines Features to convert * @param {Object} [options={}] Optional parameters * @param {Object} [options.properties={}] translates GeoJSON properties to Feature * @param {boolean} [options.autoComplete=true] auto complete linestrings (matches first & last coordinates) @@ -39,7 +41,7 @@ function lineToPolygon( orderCoords?: boolean; mutate?: boolean; } = {} -) { +): Feature { // Optional parameters var properties = options.properties; var autoComplete = options.autoComplete ?? true; @@ -68,7 +70,7 @@ function lineToPolygon( * LineString to Polygon * * @private - * @param {Feature} line line + * @param {Feature|LineString|MultiLineString} line line * @param {Object} [properties] translates GeoJSON properties to Feature * @param {boolean} [autoComplete=true] auto complete linestrings * @param {boolean} [orderCoords=true] sorts linestrings to place outer ring at the first position of the coordinates diff --git a/packages/turf-line-to-polygon/package.json b/packages/turf-line-to-polygon/package.json index 581256021d..d5e6acef84 100644 --- a/packages/turf-line-to-polygon/package.json +++ b/packages/turf-line-to-polygon/package.json @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-line-to-polygon/types.ts b/packages/turf-line-to-polygon/types.ts deleted file mode 100644 index 6cd6193272..0000000000 --- a/packages/turf-line-to-polygon/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { LineString, MultiLineString } from "geojson"; -import { featureCollection, lineString, multiLineString } from "@turf/helpers"; -import { lineToPolygon } from "./index.js"; - -// Fixtures -const coords = [ - [125, -30], - [145, -30], - [145, -20], - [125, -20], - [125, -30], -]; -const line = lineString(coords); -const multiLine = multiLineString([coords, coords]); -const fc = featureCollection([line, multiLine]); - -// Assert results with types -const poly1 = lineToPolygon(line); // Feature -const poly2 = lineToPolygon(multiLine); // Feature -const poly3 = lineToPolygon(fc); // Feature diff --git a/packages/turf-mask/package.json b/packages/turf-mask/package.json index 43f37ab543..e2214de0e6 100644 --- a/packages/turf-mask/package.json +++ b/packages/turf-mask/package.json @@ -48,7 +48,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-mask/types.ts b/packages/turf-mask/types.ts deleted file mode 100644 index be388c913d..0000000000 --- a/packages/turf-mask/types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { polygon } from "@turf/helpers"; -import { mask } from "./index.js"; - -const poly1 = polygon([ - [ - [-50, 5], - [-40, -10], - [-50, -10], - [-40, 5], - [-50, 5], - ], -]); -const poly2 = polygon([ - [ - [30, 5], - [-40, -10], - [-50, -10], - [-40, 5], - [30, 5], - ], -]); - -mask(poly1); -mask(poly1, poly2); -mask(poly1, poly2, { mutate: true }); diff --git a/packages/turf-meta/package.json b/packages/turf-meta/package.json index dc149df718..ecc8475635 100644 --- a/packages/turf-meta/package.json +++ b/packages/turf-meta/package.json @@ -70,19 +70,22 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/random": "workspace:^", "@types/benchmark": "^2.1.5", + "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", "tape": "^5.7.2", "tsup": "^8.0.1", - "tsx": "^4.6.2" + "tsx": "^4.6.2", + "typescript": "^5.5.4" }, "dependencies": { "@turf/helpers": "workspace:^", - "@types/geojson": "^7946.0.10" + "@types/geojson": "^7946.0.10", + "tslib": "^2.6.2" } } diff --git a/packages/turf-meta/types.ts b/packages/turf-meta/types.ts deleted file mode 100644 index cd2e3a04ba..0000000000 --- a/packages/turf-meta/types.ts +++ /dev/null @@ -1,340 +0,0 @@ -import { Point, LineString } from "geojson"; -import * as helpers from "@turf/helpers"; -import { featureCollection, point, lineString } from "@turf/helpers"; -import * as meta from "./index.js"; -import { - coordReduce, - coordEach, - propEach, - propReduce, - featureReduce, - featureEach, - coordAll, - geomReduce, - geomEach, - flattenReduce, - flattenEach, - segmentReduce, - segmentEach, - lineReduce, - lineEach, -} from "./index.js"; - -// Fixtures -const pt = helpers.point([0, 0]); -const line = helpers.lineString([ - [0, 0], - [1, 1], -]); -const poly = helpers.polygon([ - [ - [0, 0], - [1, 1], - [0, 1], - [0, 0], - ], -]); -const multiPoly = helpers.multiPolygon([ - [ - [ - [0, 0], - [1, 1], - [0, 1], - [0, 0], - ], - ], -]); -const multiLine = helpers.multiLineString([ - [ - [0, 0], - [1, 1], - [0, 1], - [0, 0], - ], - [ - [2, 2], - [3, 3], - ], -]); -const geomCollection = helpers.geometryCollection([pt.geometry, line.geometry]); -const features = helpers.featureCollection([pt, line]); - -const customPoint = point([10, 20], { foo: "abc", bar: 123 }); -const customPoints = featureCollection([customPoint]); -const customLineString = lineString( - [ - [0, 0], - [10, 20], - ], - { foo: "abc", bar: 123 } -); -const customLineStrings = featureCollection([customLineString]); - -/** - * meta.coordEach - */ -const coordEachValue: void = meta.coordEach(pt, (coords) => coords); -coordEach(pt, (coords, index) => coords); -meta.coordEach(pt, (coords, index) => coords); -meta.coordEach(pt.geometry, (coords) => { - const equal: number[] = coords; -}); -meta.coordEach(line, (coords) => { - const equal: number[] = coords; -}); -meta.coordEach(poly, (coords) => { - const equal: number[] = coords; -}); -meta.coordEach(multiPoly, (coords) => { - const equal: number[] = coords; -}); -meta.coordEach(geomCollection, (coords) => coords); - -/** - * meta.coordReduce - */ -const coordReduceValue: number = meta.coordReduce( - pt, - (previous, coords) => 1 + 1 -); -coordReduce(pt, (previous, coords, index) => coords); -meta.coordReduce(pt, (previous, coords, index) => coords); -meta.coordReduce(pt, (previous, coords, index) => 1 + 1, 0); -meta.coordReduce(pt, (previous, coords) => coords); -meta.coordReduce(geomCollection, (previous, coords) => coords); - -/** - * meta.propReduce - */ -const propReduceValue: number = meta.propReduce( - poly, - (previous, prop) => 1 + 1 -); -propReduce(poly, (previous, prop) => 1 + 1, 0); -meta.propReduce(poly, (previous, prop) => 1 + 1, 0); -meta.propReduce(features, (previous, prop) => prop); -meta.propReduce(poly, (previous, prop, index) => prop); -meta.propReduce(poly, (previous, prop) => 1 + 1); -meta.propReduce(geomCollection, (previous, prop) => prop); - -/** - * meta.propEach - */ -const propEachValue: void = meta.propEach(poly, (prop) => prop); -propEach(features, (prop) => prop); -meta.propEach(features, (prop) => prop); -meta.propEach(poly, (prop, index) => prop); -meta.propEach<{ bar: string }>(poly, (prop) => prop.bar); -meta.propEach(geomCollection, (prop) => prop); - -/** - * meta.coordAll - */ -coordAll(poly); -const coords: Array> = meta.coordAll(poly); - -/** - * meta.featureReduce - */ -const featureReduceValue: number = meta.featureReduce( - poly, - (previous, feature) => 1 + 1 -); -featureReduce(poly, (previous, feature) => 1 + 1, 0); -meta.featureReduce(poly, (previous, feature) => 1 + 1, 0); -meta.featureReduce(features, (previous, feature) => feature); -meta.featureReduce(poly, (previous, feature, index) => feature); -meta.featureReduce(geomCollection, (previous, feature, index) => feature); - -/** - * meta.featureEach - */ -const featureEachValue: void = meta.featureEach(poly, (feature) => feature); -featureEach(features, (feature) => feature); -meta.featureEach(features, (feature) => feature); -meta.featureEach(poly, (feature, index) => feature); -meta.featureEach(geomCollection, (feature, index) => feature); - -// Access custom properties -featureEach(customPoints, (pt) => { - pt.properties.bar; - // pt.properties.hello // [ts] Property 'hello' does not exist on type '{ foo: string; bar: number; }'. -}); - -/** - * meta.geomReduce - */ -const geomReduceValue: number = meta.geomReduce( - poly, - (previous, geom) => 1 + 1 -); -geomReduce(poly, (previous, geom) => 1 + 1, 0); -meta.geomReduce(poly, (previous, geom) => 1 + 1, 0); -meta.geomReduce(features, (previous, geom) => geom); -meta.geomReduce(poly, (previous, geom, index, props) => geom); -meta.geomReduce(geomCollection, (previous, geom, index, props) => geom); - -/** - * meta.geomEach - */ -const geomEachValue: void = meta.geomEach(poly, (geom) => geom); -geomEach(features, (geom) => geom); -meta.geomEach(features, (geom) => geom); -meta.geomEach(poly, (geom, index, props) => geom); -meta.geomEach(geomCollection, (geom, index, props) => geom); - -/** - * meta.flattenReduce - */ -const flattenReduceValue: number = meta.flattenReduce( - poly, - (previous, feature) => 1 + 1 -); -flattenReduce(poly, (previous, feature) => 1 + 1, 0); -meta.flattenReduce(poly, (previous, feature) => 1 + 1, 0); -meta.flattenReduce(features, (previous, feature) => feature); -meta.flattenReduce(poly, (previous, feature, index, props) => feature); -meta.flattenReduce( - geomCollection, - (previous, feature, index, props) => feature -); - -/** - * meta.flattenEach - */ -const flattenEachValue: void = meta.flattenEach(poly, (feature) => feature); -flattenEach(features, (feature) => feature); -meta.flattenEach(features, (feature) => feature); -meta.flattenEach(poly.geometry, (feature, index, props) => feature); -meta.flattenEach(geomCollection, (feature, index, props) => feature); - -/** - * meta.segmentReduce - */ -const lines = helpers.featureCollection([line]); -const segmentReduceValue: number = meta.segmentReduce(poly, () => 1 + 1); -segmentReduce(poly, (previousValue) => previousValue); -meta.segmentReduce(poly, (previousValue) => previousValue); -meta.segmentReduce(poly, (previousValue, currentSegment) => currentSegment); -meta.segmentReduce(poly, (previousValue, currentSegment) => 1 + 1, 0); -meta.segmentReduce(lines, (previousValue, currentSegment) => currentSegment); -meta.segmentReduce( - poly, - (previousValue, currentSegment, currentIndex) => currentSegment -); -meta.segmentReduce( - geomCollection, - (previousValue, currentSegment, currentIndex) => currentSegment -); -meta.segmentReduce( - geomCollection, - (previousValue, currentSegment, currentIndex, currentSubIndex) => - currentSegment -); - -/** - * meta.segmentEach - */ -const segmentEachValue: void = meta.segmentEach(poly, () => { - /* no-op */ -}); -segmentEach(poly, (currentSegment) => currentSegment); -meta.segmentEach(poly, (currentSegment) => currentSegment); -meta.segmentEach(features, (currentSegment) => currentSegment); -meta.segmentEach( - poly.geometry, - (currentSegment, currentIndex) => currentSegment -); -meta.segmentEach( - geomCollection, - (currentSegment, currentIndex) => currentSegment -); -meta.segmentEach( - geomCollection, - (currentSegment, currentIndex, currentSubIndex) => currentSegment -); - -/** - * meta.lineEach - */ -// meta.lineEach(pt, () => {}) // Argument of type 'Feature' is not assignable to parameter of type 'LineString | Polygon | MultiPolygon | MultiLineString | Feature'. -const lineEachValue: void = meta.lineEach(line, () => { - /* no-op */ -}); -lineEach(line, (currentLine) => currentLine); -meta.lineEach(line, (currentLine) => currentLine); -meta.lineEach( - multiLine, - (currentLine, featureIndex, featureSubIndex) => currentLine -); -meta.lineEach(poly, (currentLine) => currentLine); -meta.lineEach( - poly, - (currentLine, featureIndex, featureSubIndex, lineIndex) => currentLine -); -meta.lineEach( - multiPoly, - (currentLine, featureIndex, featureSubIndex, lineIndex) => currentLine -); - -// Able to load custom LineStrings -lineEach(customLineString, (line) => { - /* no-op */ -}); -lineEach(customLineStrings, (line) => { - line.properties.bar; - // line.properties.hello // [ts] Property 'hello' does not exist on type '{ foo: string; bar: string; }'. -}); - -/** - * meta.lineReduce - */ -// meta.lineReduce(pt, () => {}) // Argument of type 'Feature' is not assignable to parameter of type 'LineString | Polygon | MultiPolygon | MultiLineString | Feature'. -const lineReduceValue: number = meta.lineReduce(line, () => 1 + 1); -lineReduce(line, (previousValue) => previousValue); -meta.lineReduce(line, (previousValue) => previousValue); -meta.lineReduce(line, (previousValue, currentLine) => currentLine); -meta.lineReduce(line, (previousValue, currentLine) => 1 + 1, 0); -meta.lineReduce(multiLine, (previousValue, currentLine) => currentLine); -meta.lineReduce( - multiLine, - (previousValue, currentLine, featureIndex, featureSubIndex) => currentLine -); -meta.lineReduce(poly, (previousValue, currentLine) => currentLine); -meta.lineReduce( - poly, - (previousValue, currentLine, featureIndex, featureSubIndex) => currentLine -); -meta.lineReduce( - poly, - (previousValue, currentLine, featureIndex, featureSubIndex) => 1 + 1, - 1 -); -meta.lineReduce( - multiPoly, - (previousValue, currentLine, featureIndex, featureSubIndex, lineIndex) => - currentLine -); -meta.lineReduce( - multiPoly, - (previousValue, currentLine, featureIndex, featureSubIndex, lineIndex) => - 1 + 1, - 1 -); - -/** - * findSegment - */ -meta.findSegment(line); -meta.findSegment(line.geometry); -meta.findSegment(line, { segmentIndex: -1 }); - -/** - * findPoint - */ -meta.findPoint(line); -meta.findPoint(line.geometry); -meta.findPoint(line, { coordIndex: -1 }); -meta.findPoint(customLineString).properties.foo; -meta.findPoint(customLineString).properties.bar; -// meta.findPoint(customLineString).properties.hello // [ts] Property 'hello' does not exist on type '{ foo: string; bar: number; }'. diff --git a/packages/turf-midpoint/package.json b/packages/turf-midpoint/package.json index 22e74d989c..fff8d5120f 100644 --- a/packages/turf-midpoint/package.json +++ b/packages/turf-midpoint/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-moran-index/package.json b/packages/turf-moran-index/package.json index 23b34f5263..b55e49081e 100644 --- a/packages/turf-moran-index/package.json +++ b/packages/turf-moran-index/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-nearest-neighbor-analysis/package.json b/packages/turf-nearest-neighbor-analysis/package.json index 938990c4c9..d52546c85d 100644 --- a/packages/turf-nearest-neighbor-analysis/package.json +++ b/packages/turf-nearest-neighbor-analysis/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-nearest-point-on-line/package.json b/packages/turf-nearest-point-on-line/package.json index 7fcc0388db..291e23275e 100644 --- a/packages/turf-nearest-point-on-line/package.json +++ b/packages/turf-nearest-point-on-line/package.json @@ -43,7 +43,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/along": "workspace:^", diff --git a/packages/turf-nearest-point-on-line/types.ts b/packages/turf-nearest-point-on-line/types.ts deleted file mode 100644 index 8f428a149f..0000000000 --- a/packages/turf-nearest-point-on-line/types.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { nearestPointOnLine } from "./index.js"; -import { point, lineString, multiLineString } from "@turf/helpers"; - -const pt = point([1.5, 1.5]); -const line = lineString([ - [0, 0], - [1, 1], -]); -const multiLine = multiLineString([ - [ - [0, 0], - [1, 1], - [2, 2], - [0, 0], - ], -]); - -// All combinations of parameters -nearestPointOnLine(line, pt); -nearestPointOnLine(multiLine, pt); -nearestPointOnLine(line.geometry, pt); -nearestPointOnLine(multiLine.geometry, pt); -nearestPointOnLine(line, pt, { units: "miles" }); - -// Output can be used as Input -const output = nearestPointOnLine(line, pt); -nearestPointOnLine(line, output); - -// Extra properties being generated from module -output.properties.dist; -output.properties.multiFeatureIndex; -output.properties.index; -output.properties.location; diff --git a/packages/turf-nearest-point-to-line/package.json b/packages/turf-nearest-point-to-line/package.json index 95efad55b0..7bb9b78025 100644 --- a/packages/turf-nearest-point-to-line/package.json +++ b/packages/turf-nearest-point-to-line/package.json @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/circle": "workspace:^", diff --git a/packages/turf-nearest-point-to-line/types.ts b/packages/turf-nearest-point-to-line/types.ts deleted file mode 100644 index aca829901d..0000000000 --- a/packages/turf-nearest-point-to-line/types.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { - geometryCollection, - featureCollection, - point, - lineString, -} from "@turf/helpers"; -import { nearestPointToLine } from "./index.js"; - -const points = featureCollection([point([0, 0]), point([0.5, 0.5])]); -const line = lineString([ - [1, 1], - [-1, 1], -]); - -const nearest = nearestPointToLine<{ foo: string; dist: number }>( - points, - line, - { properties: { foo: "bar" } } -); -nearest.properties.foo; -nearest.properties.dist; -// nearest.properties.bar // [ts] Property 'bar' does not exist on type '{ dist?: number; foo: string; }'. - -// GeometryCollection -const geomPoints = geometryCollection([ - point([0, 0]).geometry, - point([0.5, 0.5]).geometry, -]); -nearestPointToLine(geomPoints, line); diff --git a/packages/turf-nearest-point/package.json b/packages/turf-nearest-point/package.json index 99964c06c5..59b0b5a3aa 100644 --- a/packages/turf-nearest-point/package.json +++ b/packages/turf-nearest-point/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-nearest-point/types.ts b/packages/turf-nearest-point/types.ts deleted file mode 100644 index 4aeb5ac610..0000000000 --- a/packages/turf-nearest-point/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { point, featureCollection } from "@turf/helpers"; -import { nearestPoint } from "./index.js"; - -const targetPoint = point([28.965797, 41.010086], { "marker-color": "#0F0" }); -const points = featureCollection([ - point([28.973865, 41.011122]), - point([28.948459, 41.024204]), - point([28.938674, 41.013324]), -]); -const nearest = nearestPoint(targetPoint, points, { units: "kilometers" }); -nearest.properties.distanceToPoint; -nearest.properties.featureIndex; diff --git a/packages/turf-planepoint/package.json b/packages/turf-planepoint/package.json index 56240f17cc..05aee89b33 100644 --- a/packages/turf-planepoint/package.json +++ b/packages/turf-planepoint/package.json @@ -50,7 +50,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-planepoint/types.ts b/packages/turf-planepoint/types.ts deleted file mode 100644 index edbbb1739c..0000000000 --- a/packages/turf-planepoint/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { point, polygon } from "@turf/helpers"; -import { planepoint } from "./index.js"; - -const pt = point([1, 1]); -const triangle = polygon([ - [ - [0, 0, 0], - [2, 0, 0], - [1, 2, 2], - [0, 0, 0], - ], -]); - -planepoint(pt, triangle); -planepoint(pt.geometry.coordinates, triangle); -planepoint(pt.geometry, triangle.geometry); diff --git a/packages/turf-point-grid/package.json b/packages/turf-point-grid/package.json index eacb2443e2..2ceae51452 100644 --- a/packages/turf-point-grid/package.json +++ b/packages/turf-point-grid/package.json @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-point-grid/types.ts b/packages/turf-point-grid/types.ts deleted file mode 100644 index 8eb9a3eb13..0000000000 --- a/packages/turf-point-grid/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { BBox } from "geojson"; -import { polygon } from "@turf/helpers"; -import { pointGrid } from "./index.js"; - -const cellSide = 50; -const bbox: BBox = [-95, 30, -85, 40]; -const poly = polygon([ - [ - [20, 30], - [10, 10], - [20, 20], - [20, 30], - ], -]); - -pointGrid(bbox, cellSide); -pointGrid(bbox, cellSide, { units: "miles" }); -pointGrid(bbox, cellSide, { units: "miles", mask: poly }); -pointGrid(bbox, cellSide, { - units: "miles", - mask: poly, - properties: { foo: "bar" }, -}); diff --git a/packages/turf-point-on-feature/package.json b/packages/turf-point-on-feature/package.json index 36f7db65cd..7053aeccde 100644 --- a/packages/turf-point-on-feature/package.json +++ b/packages/turf-point-on-feature/package.json @@ -50,7 +50,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/meta": "workspace:^", diff --git a/packages/turf-point-to-line-distance/package.json b/packages/turf-point-to-line-distance/package.json index e9c63b2a30..8408a73857 100644 --- a/packages/turf-point-to-line-distance/package.json +++ b/packages/turf-point-to-line-distance/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/circle": "workspace:^", diff --git a/packages/turf-point-to-line-distance/types.ts b/packages/turf-point-to-line-distance/types.ts deleted file mode 100644 index b9c198b17b..0000000000 --- a/packages/turf-point-to-line-distance/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { point, lineString } from "@turf/helpers"; -import { pointToLineDistance } from "./index.js"; - -const pt = point([0, 0]); -const line = lineString([ - [1, 1], - [-1, 1], -]); -const distance: number = pointToLineDistance(pt, line, { units: "miles" }); - -pointToLineDistance(pt, line); -pointToLineDistance(pt, line, { units: "miles" }); -pointToLineDistance(pt, line, { units: "miles", method: "planar" }); diff --git a/packages/turf-points-within-polygon/package.json b/packages/turf-points-within-polygon/package.json index fd0828e0d1..4a0d5e97fa 100644 --- a/packages/turf-points-within-polygon/package.json +++ b/packages/turf-points-within-polygon/package.json @@ -50,7 +50,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-points-within-polygon/types.ts b/packages/turf-points-within-polygon/types.ts deleted file mode 100644 index 8597843653..0000000000 --- a/packages/turf-points-within-polygon/types.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Point, MultiPoint } from "geojson"; -import { pointsWithinPolygon } from "./index.js"; -import { points, polygon, multiPoint, featureCollection } from "@turf/helpers"; - -const pts = points([ - [-46.6318, -23.5523], - [-46.6246, -23.5325], - [-46.6062, -23.5513], - [-46.663, -23.554], - [-46.643, -23.557], -]); -const mpt1 = multiPoint( - [ - [50, 50], - [100, 100], - ], - {} -); -const mpt2 = multiPoint( - [ - [75, 75], - [150, 150], - ], - {} -); -const mpts = featureCollection([mpt1, mpt2]); - -const searchWithin = polygon([ - [ - [-46.653, -23.543], - [-46.634, -23.5346], - [-46.613, -23.543], - [-46.614, -23.559], - [-46.631, -23.567], - [-46.653, -23.56], - [-46.653, -23.543], - ], -]); -const ptsWithin = pointsWithinPolygon(pts, searchWithin); -const mptsWithin = pointsWithinPolygon(mpts, searchWithin); - -// Accepts a mixture of Point and MultiPoint -const mix = featureCollection([...pts.features, mpt1]); -const mixWithin = pointsWithinPolygon(mix, searchWithin); diff --git a/packages/turf-polygon-smooth/package.json b/packages/turf-polygon-smooth/package.json index e035c4c884..739ddd2e9f 100644 --- a/packages/turf-polygon-smooth/package.json +++ b/packages/turf-polygon-smooth/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-polygon-smooth/types.ts b/packages/turf-polygon-smooth/types.ts deleted file mode 100644 index 1519280ad0..0000000000 --- a/packages/turf-polygon-smooth/types.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { polygon } from "@turf/helpers"; -import { polygonSmooth } from "./index.js"; - -const poly = polygon([ - [ - [100.0, 0.0], - [101.0, 0.0], - [101.0, 1.0], - [100.0, 1.0], - [100.0, 0.0], - ], -]); - -polygonSmooth(poly); -polygonSmooth(poly, { iterations: 3 }); diff --git a/packages/turf-polygon-tangents/package.json b/packages/turf-polygon-tangents/package.json index eede9b5ee0..d3cc469b60 100644 --- a/packages/turf-polygon-tangents/package.json +++ b/packages/turf-polygon-tangents/package.json @@ -54,7 +54,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-polygon-tangents/test.ts b/packages/turf-polygon-tangents/test.ts index cae2f35ab5..19b4f21e4d 100644 --- a/packages/turf-polygon-tangents/test.ts +++ b/packages/turf-polygon-tangents/test.ts @@ -105,7 +105,7 @@ test("turf-polygon-tangents - Issue #1050", (t) => { try { t.assert(polygonTangents(pt, poly)); } catch (e) { - t.skip("issue #1050 failed"); + t.skip("issue #1050 failed", e); } t.end(); }); diff --git a/packages/turf-polygon-tangents/types.ts b/packages/turf-polygon-tangents/types.ts deleted file mode 100644 index dd02ba927d..0000000000 --- a/packages/turf-polygon-tangents/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { polygon, point } from "@turf/helpers"; -import { polygonTangents as tangents } from "./index.js"; - -const poly = polygon([ - [ - [11, 0], - [22, 4], - [31, 0], - [31, 11], - [21, 15], - [11, 11], - [11, 0], - ], -]); -const pt = point([61, 5]); -tangents(pt, poly); diff --git a/packages/turf-polygon-to-line/package.json b/packages/turf-polygon-to-line/package.json index 54315bbb6b..f1767a4f84 100644 --- a/packages/turf-polygon-to-line/package.json +++ b/packages/turf-polygon-to-line/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-polygonize/README.md b/packages/turf-polygonize/README.md index 48f42a366f..131ce19403 100644 --- a/packages/turf-polygonize/README.md +++ b/packages/turf-polygonize/README.md @@ -18,11 +18,11 @@ The implementation correctly handles: ### Parameters -* `geoJson` **([FeatureCollection][3] | [Geometry][4] | [Feature][5]<([LineString][1] | [MultiLineString][6])>)** Lines in order to polygonize +* `geoJson` **([FeatureCollection][3]<([LineString][1] | [MultiLineString][4])> | [Feature][5]<([LineString][1] | [MultiLineString][4])> | [LineString][1] | [MultiLineString][4])** Lines in order to polygonize -* Throws **[Error][7]** if geoJson is invalid. +* Throws **[Error][6]** if geoJson is invalid. Returns **[FeatureCollection][3]<[Polygon][2]>** Polygons created @@ -32,13 +32,11 @@ Returns **[FeatureCollection][3]<[Polygon][2]>** Polygons created [3]: https://tools.ietf.org/html/rfc7946#section-3.3 -[4]: https://tools.ietf.org/html/rfc7946#section-3.1 +[4]: https://tools.ietf.org/html/rfc7946#section-3.1.5 [5]: https://tools.ietf.org/html/rfc7946#section-3.2 -[6]: https://tools.ietf.org/html/rfc7946#section-3.1.5 - -[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error diff --git a/packages/turf-polygonize/index.ts b/packages/turf-polygonize/index.ts index 30f4e75295..1ccc3eb1b1 100644 --- a/packages/turf-polygonize/index.ts +++ b/packages/turf-polygonize/index.ts @@ -23,7 +23,7 @@ import { EdgeRing } from "./lib/EdgeRing.js"; * - Cut Edges (bridges): edges that are connected at both ends but which do not form part of a polygon. * * @name polygonize - * @param {FeatureCollection|Geometry|Feature} geoJson Lines in order to polygonize + * @param {FeatureCollection|Feature|LineString|MultiLineString} geoJson Lines in order to polygonize * @returns {FeatureCollection} Polygons created * @throws {Error} if geoJson is invalid. */ diff --git a/packages/turf-polygonize/lib/Edge.ts b/packages/turf-polygonize/lib/Edge.ts index 76239e3530..96f71820e8 100644 --- a/packages/turf-polygonize/lib/Edge.ts +++ b/packages/turf-polygonize/lib/Edge.ts @@ -1,3 +1,4 @@ +import { Feature, LineString } from "geojson"; import { lineString } from "@turf/helpers"; import { orientationIndex } from "./util.js"; import { Node } from "./Node.js"; @@ -74,7 +75,7 @@ class Edge { * * @returns {Feature} - LineString representation of the Edge */ - toLineString() { + toLineString(): Feature { return lineString([this.from.coordinates, this.to.coordinates]); } diff --git a/packages/turf-polygonize/lib/EdgeRing.ts b/packages/turf-polygonize/lib/EdgeRing.ts index c087cb3887..9d469aef5b 100644 --- a/packages/turf-polygonize/lib/EdgeRing.ts +++ b/packages/turf-polygonize/lib/EdgeRing.ts @@ -1,4 +1,4 @@ -import { Polygon, Feature, Point, Position } from "geojson"; +import { Polygon, Feature, MultiPoint, Point, Position } from "geojson"; import { orientationIndex, envelopeIsEqual, @@ -156,7 +156,7 @@ class EdgeRing { * @memberof EdgeRing * @returns {Feature} - Multipoint representation of the EdgeRing */ - toMultiPoint() { + toMultiPoint(): Feature { return multiPoint(this.edges.map((edge) => edge.from.coordinates)); } diff --git a/packages/turf-polygonize/package.json b/packages/turf-polygonize/package.json index 8e0fcf805c..c10b8dd06a 100644 --- a/packages/turf-polygonize/package.json +++ b/packages/turf-polygonize/package.json @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-polygonize/types.ts b/packages/turf-polygonize/types.ts deleted file mode 100644 index 80bc1e456c..0000000000 --- a/packages/turf-polygonize/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { lineString } from "@turf/helpers"; -import { polygonize } from "./index.js"; - -const line = lineString([ - [10, 10], - [0, 0], - [3, -5], - [10, 10], -]); -polygonize(line); diff --git a/packages/turf-projection/package.json b/packages/turf-projection/package.json index 431910abc0..fbc42279e9 100644 --- a/packages/turf-projection/package.json +++ b/packages/turf-projection/package.json @@ -61,7 +61,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-projection/types.ts b/packages/turf-projection/types.ts deleted file mode 100644 index 55e7ead1f2..0000000000 --- a/packages/turf-projection/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as projection from "./index.js"; -import { toMercator, toWgs84 } from "./index.js"; -import { point } from "@turf/helpers"; - -// Types test -const pt = point([3, 51]); -const projected = toMercator(pt); -const degrees = toWgs84(projected); - -// default import -projection.toMercator(pt); -projection.toWgs84(projected); diff --git a/packages/turf-quadrat-analysis/package.json b/packages/turf-quadrat-analysis/package.json index 9093cf8613..d2668b2e88 100644 --- a/packages/turf-quadrat-analysis/package.json +++ b/packages/turf-quadrat-analysis/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/nearest-neighbor-analysis": "workspace:^", diff --git a/packages/turf-random/package.json b/packages/turf-random/package.json index 38b2c44688..2f43a69792 100644 --- a/packages/turf-random/package.json +++ b/packages/turf-random/package.json @@ -46,7 +46,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-rectangle-grid/package.json b/packages/turf-rectangle-grid/package.json index 14f0d617cb..af3e063d41 100644 --- a/packages/turf-rectangle-grid/package.json +++ b/packages/turf-rectangle-grid/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-rewind/package.json b/packages/turf-rewind/package.json index 9e04a4f630..671e3d89c9 100644 --- a/packages/turf-rewind/package.json +++ b/packages/turf-rewind/package.json @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-rewind/types.ts b/packages/turf-rewind/types.ts deleted file mode 100644 index a87727cd83..0000000000 --- a/packages/turf-rewind/types.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - polygon, - lineString, - multiLineString, - multiPolygon, -} from "@turf/helpers"; -import { rewind } from "./index.js"; - -const coords = [ - [121, -29], - [138, -29], - [138, -18], - [121, -18], - [121, -29], -]; -const poly = polygon([coords]); -const line = lineString(coords); -const multiPoly = multiPolygon([[coords], [coords]]); -const multiLine = multiLineString([coords, coords]); - -rewind(line); -rewind(poly); -rewind(multiPoly); -rewind(multiLine); -rewind(poly, { mutate: true }); -rewind(poly, { mutate: true, reverse: true }); diff --git a/packages/turf-rhumb-bearing/package.json b/packages/turf-rhumb-bearing/package.json index 6410eb40d3..0af99dabae 100644 --- a/packages/turf-rhumb-bearing/package.json +++ b/packages/turf-rhumb-bearing/package.json @@ -54,7 +54,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/destination": "workspace:^", diff --git a/packages/turf-rhumb-destination/package.json b/packages/turf-rhumb-destination/package.json index 79e08a3e16..249ac18df1 100644 --- a/packages/turf-rhumb-destination/package.json +++ b/packages/turf-rhumb-destination/package.json @@ -58,7 +58,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-rhumb-distance/package.json b/packages/turf-rhumb-distance/package.json index 06d996034f..01274b0218 100644 --- a/packages/turf-rhumb-distance/package.json +++ b/packages/turf-rhumb-distance/package.json @@ -56,7 +56,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/distance": "workspace:^", diff --git a/packages/turf-sample/package.json b/packages/turf-sample/package.json index e27419b91a..d667ae13ff 100644 --- a/packages/turf-sample/package.json +++ b/packages/turf-sample/package.json @@ -48,7 +48,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-sector/package.json b/packages/turf-sector/package.json index 5c25792698..ad415ee4f4 100644 --- a/packages/turf-sector/package.json +++ b/packages/turf-sector/package.json @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-sector/types.ts b/packages/turf-sector/types.ts deleted file mode 100644 index acc42b6b33..0000000000 --- a/packages/turf-sector/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { point } from "@turf/helpers"; -import { sector } from "./index.js"; - -const center = point([-75.343, 39.984]); -const units = "kilometers"; -const bearing1 = 10; -const bearing2 = -30; -const radius = 5; -const steps = 10; - -sector(center, radius, bearing1, bearing2); -sector(center, radius, bearing1, bearing2, { steps }); -sector(center, radius, bearing1, bearing2, { steps, units }); diff --git a/packages/turf-shortest-path/package.json b/packages/turf-shortest-path/package.json index a08a1326d0..4267e4a913 100644 --- a/packages/turf-shortest-path/package.json +++ b/packages/turf-shortest-path/package.json @@ -52,7 +52,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-shortest-path/types.ts b/packages/turf-shortest-path/types.ts deleted file mode 100644 index 845fa80144..0000000000 --- a/packages/turf-shortest-path/types.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { point, featureCollection, polygon } from "@turf/helpers"; -import { shortestPath } from "./index.js"; - -const start = point([-5, -6]); -const end = point([9, -6]); - -shortestPath(start.geometry, end.geometry.coordinates); -shortestPath(start, end); -shortestPath(start, end, { - obstacles: polygon([ - [ - [0, -7], - [5, -7], - [5, -3], - [0, -3], - [0, -7], - ], - ]), -}); -shortestPath(start, end, { - obstacles: featureCollection([ - polygon([ - [ - [0, -7], - [5, -7], - [5, -3], - [0, -3], - [0, -7], - ], - ]), - ]), -}); -shortestPath(start, end, { - resolution: 1000, -}); diff --git a/packages/turf-simplify/package.json b/packages/turf-simplify/package.json index cb1edd5e07..40933aa661 100644 --- a/packages/turf-simplify/package.json +++ b/packages/turf-simplify/package.json @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-simplify/types.ts b/packages/turf-simplify/types.ts deleted file mode 100644 index c5d5dda23a..0000000000 --- a/packages/turf-simplify/types.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Feature, Polygon } from "geojson"; -import { polygon } from "@turf/helpers"; -import { simplify } from "./index.js"; - -const poly = polygon([ - [ - [0, 0], - [10, 10], - [20, 20], - [0, 0], - ], -]); - -// Output type is the same as Input type -const simple: Feature = simplify(poly); - -// Extra params -simplify(poly, { tolerance: 1 }); -simplify(poly, { tolerance: 1, highQuality: true }); diff --git a/packages/turf-square-grid/package.json b/packages/turf-square-grid/package.json index 4b00386036..ecc26db5d9 100644 --- a/packages/turf-square-grid/package.json +++ b/packages/turf-square-grid/package.json @@ -49,7 +49,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-square/package.json b/packages/turf-square/package.json index 91807bf787..fe9d2d2c41 100644 --- a/packages/turf-square/package.json +++ b/packages/turf-square/package.json @@ -48,7 +48,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-standard-deviational-ellipse/package.json b/packages/turf-standard-deviational-ellipse/package.json index 69e3fe5dc4..1de104605f 100644 --- a/packages/turf-standard-deviational-ellipse/package.json +++ b/packages/turf-standard-deviational-ellipse/package.json @@ -52,7 +52,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/random": "workspace:^", diff --git a/packages/turf-standard-deviational-ellipse/types.ts b/packages/turf-standard-deviational-ellipse/types.ts deleted file mode 100644 index 3b7760de92..0000000000 --- a/packages/turf-standard-deviational-ellipse/types.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { points } from "@turf/helpers"; -import { standardDeviationalEllipse } from "./index.js"; - -const pts = points([ - [10, 10], - [0, 5], -]); -const stdEllipse = standardDeviationalEllipse(pts); - -// Access custom properties -// It's correct to use optional chaining here ?. as even though the function -// *always* adds properties, that does not change the overall optional nature of -// the containing properties attribute. -stdEllipse.properties?.standardDeviationalEllipse.meanCenterCoordinates; diff --git a/packages/turf-tag/package.json b/packages/turf-tag/package.json index 692c483a1f..8385387722 100644 --- a/packages/turf-tag/package.json +++ b/packages/turf-tag/package.json @@ -52,7 +52,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-tesselate/package.json b/packages/turf-tesselate/package.json index 048cfee32d..22ee382d1e 100644 --- a/packages/turf-tesselate/package.json +++ b/packages/turf-tesselate/package.json @@ -56,7 +56,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-tesselate/tsconfig.json b/packages/turf-tesselate/tsconfig.json index 563bf86442..05f6b84c5a 100644 --- a/packages/turf-tesselate/tsconfig.json +++ b/packages/turf-tesselate/tsconfig.json @@ -1,3 +1,4 @@ { - "extends": "../../tsconfig.shared.json" + "extends": "../../tsconfig.shared.json", + "files": ["index.ts", "earcut.d.ts"] } diff --git a/packages/turf-tin/package.json b/packages/turf-tin/package.json index 2dd2f78174..3db88f800f 100644 --- a/packages/turf-tin/package.json +++ b/packages/turf-tin/package.json @@ -48,7 +48,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-tin/types.ts b/packages/turf-tin/types.ts deleted file mode 100644 index 2802fb41f8..0000000000 --- a/packages/turf-tin/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { featureCollection, point } from "@turf/helpers"; -import { tin } from "./index.js"; - -const points = featureCollection([ - point([0, 0], { elevation: 20 }), - point([10, 10], { elevation: 10 }), - point([30, 30], { elevation: 50 }), -]); -tin(points); -tin(points, "elevation"); diff --git a/packages/turf-transform-rotate/package.json b/packages/turf-transform-rotate/package.json index 9bcb716513..6418ba89c6 100644 --- a/packages/turf-transform-rotate/package.json +++ b/packages/turf-transform-rotate/package.json @@ -53,7 +53,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-transform-rotate/types.ts b/packages/turf-transform-rotate/types.ts deleted file mode 100644 index cb0f0af6fb..0000000000 --- a/packages/turf-transform-rotate/types.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Point, Feature, Polygon, FeatureCollection } from "geojson"; -import { - polygon, - point, - featureCollection, - geometryCollection, -} from "@turf/helpers"; -import { transformRotate as rotate } from "./index.js"; - -const pt = point([15, 15]); -const poly = polygon([ - [ - [0, 29], - [3.5, 29], - [2.5, 32], - [0, 29], - ], -]); - -// Does not mutate Geometry type -const rotatedPoly: Feature = rotate(poly, 100, { pivot: pt }); -const rotatedFCPoly: FeatureCollection = rotate( - featureCollection([poly]), - 100, - { pivot: pt } -); - -// Different Geometry Inputs -rotate(poly, 100, { pivot: pt }); -rotate(poly, 100, { pivot: pt.geometry }); -rotate(poly.geometry, 100, { pivot: pt.geometry.coordinates }); -rotate(featureCollection([poly]), 100, { pivot: pt.geometry }); -rotate(featureCollection([poly, pt]), 100, { pivot: pt }); -rotate(geometryCollection([poly.geometry]).geometry, 100, { - pivot: pt.geometry, -}); -rotate(geometryCollection([poly.geometry]), 100, { pivot: pt.geometry }); -rotate(geometryCollection([poly.geometry, pt.geometry]), 100, { pivot: pt }); - -// Allow mutating -rotate(poly, 100, { pivot: pt, mutate: true }); diff --git a/packages/turf-transform-scale/package.json b/packages/turf-transform-scale/package.json index 61acb936bf..622a19241c 100644 --- a/packages/turf-transform-scale/package.json +++ b/packages/turf-transform-scale/package.json @@ -57,7 +57,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-transform-scale/types.ts b/packages/turf-transform-scale/types.ts deleted file mode 100644 index e4e3bcf0d8..0000000000 --- a/packages/turf-transform-scale/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { LineString, Feature, Polygon } from "geojson"; -import { lineString, polygon, featureCollection } from "@turf/helpers"; -import { transformScale as scale } from "./index.js"; - -const line = lineString([ - [0, 0], - [10, 29], -]); -const poly = polygon([ - [ - [0, 29], - [3.5, 29], - [2.5, 32], - [0, 29], - ], -]); - -// Does not mutate Geometry type -const scaledPt: LineString = scale(line.geometry, 1.5); -const scaledPoly: Feature = scale(poly, 1.5); - -// Diferent Geometry inputs -scale(line.geometry, 1.5); -scale(poly.geometry, 1.5); -scale(featureCollection([poly]), 1.5); - -// All params -scale(poly, 1.5); -scale(poly, 1.5, { origin: [10, 10] }); -scale(poly, 1.5, { origin: "ne", mutate: true }); diff --git a/packages/turf-transform-translate/package.json b/packages/turf-transform-translate/package.json index e129b04297..ee487d7602 100644 --- a/packages/turf-transform-translate/package.json +++ b/packages/turf-transform-translate/package.json @@ -55,7 +55,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/truncate": "workspace:^", diff --git a/packages/turf-transform-translate/types.ts b/packages/turf-transform-translate/types.ts deleted file mode 100644 index 303eebe68f..0000000000 --- a/packages/turf-transform-translate/types.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Point, Feature, Polygon } from "geojson"; -import { point, polygon, featureCollection } from "@turf/helpers"; -import { transformTranslate as translate } from "./index.js"; - -const pt = point([0, 0]); -const poly = polygon([ - [ - [0, 29], - [3.5, 29], - [2.5, 32], - [0, 29], - ], -]); - -// Does not mutate Geometry type -const translatedPt: Point = translate(pt.geometry, 100, 35); -const translatedPoly: Feature = translate(poly, 100, 35); - -// Diferent Geometry inputs -translate(pt.geometry, 100, 35); -translate(poly.geometry, 100, 35); -translate(featureCollection([poly]), 100, 35); - -// All params -translate(poly, 100, 35, { units: "kilometers" }); -translate(poly, 100, 35, { units: "kilometers", zTranslation: 10 }); -translate(poly, 100, 35, { - units: "kilometers", - zTranslation: 10, - mutate: true, -}); diff --git a/packages/turf-triangle-grid/package.json b/packages/turf-triangle-grid/package.json index fc953dffdc..47e56627fe 100644 --- a/packages/turf-triangle-grid/package.json +++ b/packages/turf-triangle-grid/package.json @@ -51,7 +51,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/bbox-polygon": "workspace:^", diff --git a/packages/turf-triangle-grid/types.ts b/packages/turf-triangle-grid/types.ts deleted file mode 100644 index 33a7b1c88a..0000000000 --- a/packages/turf-triangle-grid/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { BBox } from "geojson"; -import { triangleGrid } from "./index.js"; - -// prettier-ignore -const bbox: BBox = [ - -96.6357421875, - 31.12819929911196, - -84.9462890625, - 40.58058466412764, -]; -const grid = triangleGrid(bbox, 50, { - units: "miles", - properties: { foo: "bar" }, -}); -grid.features[0].properties.foo; -// grid.features[0].properties.bar // [ts] Property 'bar' does not exist on type '{ 'foo': string; }'. diff --git a/packages/turf-truncate/package.json b/packages/turf-truncate/package.json index 40edff7cf9..8ded1c3e46 100644 --- a/packages/turf-truncate/package.json +++ b/packages/turf-truncate/package.json @@ -52,7 +52,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-truncate/types.ts b/packages/turf-truncate/types.ts deleted file mode 100644 index e67fac78f2..0000000000 --- a/packages/turf-truncate/types.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { - featureCollection, - point, - lineString, - geometryCollection, -} from "@turf/helpers"; -import { truncate } from "./index.js"; - -const pt = point([120.1234567, 40.1234567]); -const ptGeom = pt.geometry; -const line = lineString([ - [20, 80], - [50, 40], -]); -const lineGeom = line.geometry; -const points = featureCollection([pt]); -const lines = featureCollection([line]); -const geomCollection = geometryCollection([ptGeom, lineGeom]); - -truncate(pt); -truncate(ptGeom); -truncate(line); -truncate(lineGeom); -truncate(lines); -truncate(points); -truncate(geomCollection); -truncate(pt, { precision: 6 }); -truncate(pt, { precision: 3, coordinates: 2 }); -truncate(pt, { precision: 3, coordinates: 2, mutate: false }); diff --git a/packages/turf-union/package.json b/packages/turf-union/package.json index 790c6a6fb0..f8ef7a9e05 100644 --- a/packages/turf-union/package.json +++ b/packages/turf-union/package.json @@ -47,7 +47,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf-union/types.ts b/packages/turf-union/types.ts deleted file mode 100644 index fff2c5aed2..0000000000 --- a/packages/turf-union/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { polygon, featureCollection } from "@turf/helpers"; -import { union } from "./index.js"; - -const poly1 = polygon([ - [ - [0, 0], - [10, 10], - [20, 20], - [0, 0], - ], -]); -const poly2 = polygon([ - [ - [20, 30], - [10, 10], - [20, 20], - [20, 30], - ], -]); -union(featureCollection([poly1, poly2])); diff --git a/packages/turf-unkink-polygon/package.json b/packages/turf-unkink-polygon/package.json index d0d0846227..9a18f1d4fc 100644 --- a/packages/turf-unkink-polygon/package.json +++ b/packages/turf-unkink-polygon/package.json @@ -50,7 +50,7 @@ "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", "test:tape": "tsx test.ts", - "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts" + "test:types": "tsc --noEmit" }, "devDependencies": { "@turf/kinks": "workspace:^", diff --git a/packages/turf-unkink-polygon/types.ts b/packages/turf-unkink-polygon/types.ts deleted file mode 100644 index 721492b8e1..0000000000 --- a/packages/turf-unkink-polygon/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { polygon, multiPolygon } from "@turf/helpers"; -import { unkinkPolygon as unkink } from "./index.js"; - -const poly = polygon([ - [ - [20, 30], - [10, 10], - [20, 20], - [20, 30], - ], -]); -const multiPoly = multiPolygon([ - [ - [ - [20, 30], - [10, 10], - [20, 20], - [20, 30], - ], - ], - [ - [ - [0, 0], - [10, 10], - [20, 20], - [0, 0], - ], - ], -]); - -unkink(poly); -unkink(multiPoly); diff --git a/packages/turf-voronoi/package.json b/packages/turf-voronoi/package.json index 9e4c290c98..b3dd3c8b79 100644 --- a/packages/turf-voronoi/package.json +++ b/packages/turf-voronoi/package.json @@ -55,7 +55,8 @@ "build": "tsup --config ../../tsup.config.ts", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.ts" + "test:tape": "tsx test.ts", + "test:types": "tsc --noEmit" }, "devDependencies": { "@types/benchmark": "^2.1.5", diff --git a/packages/turf/package.json b/packages/turf/package.json index 347f02d3f8..3b0b3a2d9a 100644 --- a/packages/turf/package.json +++ b/packages/turf/package.json @@ -67,11 +67,11 @@ "turf.min.js" ], "scripts": { - "build": "tsup --config ../../tsup.config.ts && rollup -c rollup.config.js", - "last-checks": "npm-run-all last-checks:testjs last-checks:example", - "last-checks:example": "tsx test.example.js", - "last-checks:testjs": "tsx test.ts", - "test": "echo '@turf/turf tests run in the last-checks step'" + "build": "tsup --config ../../tsup.config.ts", + "cdnBundle": "npm-run-all cdnBundle:minify cdnBundle:checks", + "cdnBundle:checks": "tsx test.ts && tsx test.example.js", + "cdnBundle:minify": "rollup -c rollup.config.js", + "test": "echo '@turf/turf tests run in the cdnBundle:checks step'" }, "devDependencies": { "@babel/core": "^7.23.2", @@ -80,10 +80,13 @@ "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-terser": "^0.4.4", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", + "benchmark": "^2.1.4", "camelcase": "^8.0.0", "documentation": "^14.0.3", "glob": "^10.3.10", + "npm-run-all": "^4.1.5", "rollup": "^2.79.1", "rollup-plugin-polyfill-node": "^0.13.0", "tape": "^5.7.2", diff --git a/packages/turf/rollup.config.js b/packages/turf/rollup.config.js index fc94e72a95..f7c14db656 100644 --- a/packages/turf/rollup.config.js +++ b/packages/turf/rollup.config.js @@ -4,7 +4,7 @@ import terser from "@rollup/plugin-terser"; import { babel } from "@rollup/plugin-babel"; import nodePolyfills from "rollup-plugin-polyfill-node"; -const pckg = require("./package.json"); +import pckg from "./package.json"; const input = "index.ts"; export default [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa4529be13..c848e7636c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,11 +24,11 @@ importers: specifier: 18.11.9 version: 18.11.9 '@typescript-eslint/eslint-plugin': - specifier: ^6.10.0 - version: 6.13.2(@typescript-eslint/parser@6.13.2)(eslint@8.55.0)(typescript@5.5.4) + specifier: ^8.2.0 + version: 8.2.0(@typescript-eslint/parser@8.2.0)(eslint@8.57.0)(typescript@5.5.4) '@typescript-eslint/parser': - specifier: ^6.10.0 - version: 6.13.2(eslint@8.55.0)(typescript@5.5.4) + specifier: ^8.2.0 + version: 8.2.0(eslint@8.57.0)(typescript@5.5.4) acorn: specifier: ^7.4.1 version: 7.4.1 @@ -51,14 +51,14 @@ importers: specifier: ^7.1.1 version: 7.1.1 eslint: - specifier: ^8.53.0 - version: 8.55.0 + specifier: ^8.57.0 + version: 8.57.0 eslint-config-prettier: specifier: ^9.0.0 - version: 9.1.0(eslint@8.55.0) + version: 9.1.0(eslint@8.57.0) eslint-plugin-prettier: specifier: ^5.0.1 - version: 5.0.1(eslint-config-prettier@9.1.0)(eslint@8.55.0)(prettier@3.3.3) + version: 5.0.1(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.3.3) esm: specifier: ^3.2.25 version: 3.2.25 @@ -471,9 +471,15 @@ importers: '@rollup/plugin-terser': specifier: ^0.4.4 version: 0.4.4(rollup@2.79.1) + '@types/benchmark': + specifier: ^2.1.5 + version: 2.1.5 '@types/tape': specifier: ^4.2.32 version: 4.13.4 + benchmark: + specifier: ^2.1.4 + version: 2.1.4 camelcase: specifier: ^8.0.0 version: 8.0.0 @@ -483,6 +489,9 @@ importers: glob: specifier: ^10.3.10 version: 10.3.10 + npm-run-all: + specifier: ^4.1.5 + version: 4.1.5 rollup: specifier: ^2.79.1 version: 2.79.1 @@ -1678,6 +1687,9 @@ importers: d3-geo: specifier: 1.7.1 version: 1.7.1 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/truncate': specifier: workspace:^ @@ -1706,6 +1718,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -3127,6 +3142,9 @@ importers: rbush: specifier: ^3.0.1 version: 3.0.1 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/bbox-polygon': specifier: workspace:^ @@ -3154,13 +3172,13 @@ importers: version: 5.7.2 tsup: specifier: ^8.0.1 - version: 8.0.1(postcss@8.4.40)(ts-node@9.1.1)(typescript@5.3.3) + version: 8.0.1(postcss@8.4.40)(ts-node@9.1.1)(typescript@5.5.4) tsx: specifier: ^4.6.2 version: 4.6.2 typescript: - specifier: ^5.2.2 - version: 5.3.3 + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -3176,6 +3194,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/truncate': specifier: workspace:^ @@ -3204,6 +3225,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -3338,6 +3362,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/truncate': specifier: workspace:^ @@ -3369,6 +3396,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -3775,6 +3805,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/truncate': specifier: workspace:^ @@ -3803,6 +3836,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -3870,6 +3906,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/truncate': specifier: workspace:^ @@ -3898,6 +3937,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -4029,6 +4071,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/truncate': specifier: workspace:^ @@ -4057,6 +4102,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -4078,6 +4126,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/along': specifier: workspace:^ @@ -4109,6 +4160,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 packages/turf-line-split: dependencies: @@ -4145,6 +4199,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@types/benchmark': specifier: ^2.1.5 @@ -4170,6 +4227,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 write-json-file: specifier: ^5.0.0 version: 5.0.0 @@ -4286,6 +4346,9 @@ importers: '@types/geojson': specifier: ^7946.0.10 version: 7946.0.14 + tslib: + specifier: ^2.6.2 + version: 2.6.2 devDependencies: '@turf/random': specifier: workspace:^ @@ -4293,6 +4356,9 @@ importers: '@types/benchmark': specifier: ^2.1.5 version: 2.1.5 + '@types/tape': + specifier: ^4.2.32 + version: 4.13.4 benchmark: specifier: ^2.1.4 version: 2.1.4 @@ -4308,6 +4374,9 @@ importers: tsx: specifier: ^4.6.2 version: 4.6.2 + typescript: + specifier: ^5.5.4 + version: 5.5.4 packages/turf-midpoint: dependencies: @@ -6643,7 +6712,7 @@ packages: '@babel/core': 7.23.5 '@babel/helper-compilation-targets': 7.22.15 '@babel/helper-plugin-utils': 7.22.5 - debug: 4.3.4 + debug: 4.3.6 lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -7704,7 +7773,7 @@ packages: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.23.5 '@babel/types': 7.23.5 - debug: 4.3.4 + debug: 4.3.6 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -8154,13 +8223,13 @@ packages: dev: true optional: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.55.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.57.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.55.0 + eslint: 8.57.0 eslint-visitor-keys: 3.4.3 dev: true @@ -8169,15 +8238,20 @@ packages: engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} dev: true + /@eslint-community/regexpp@4.11.0: + resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + dev: true + /@eslint/eslintrc@2.1.4: resolution: {integrity: sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.6 espree: 9.6.1 - globals: 13.23.0 - ignore: 5.3.0 + globals: 13.24.0 + ignore: 5.3.2 import-fresh: 3.3.0 js-yaml: 4.1.0 minimatch: 3.1.2 @@ -8186,8 +8260,8 @@ packages: - supports-color dev: true - /@eslint/js@8.55.0: - resolution: {integrity: sha512-qQfo2mxH5yVom1kacMtZZJFVdW+E70mqHMJvVg6WTLo+VBuQJ4TojZlfWBjK0ve5BdEeNAVxOsl/nvNMpJOaJA==} + /@eslint/js@8.57.0: + resolution: {integrity: sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -8196,12 +8270,13 @@ packages: engines: {node: '>=12.20'} dev: true - /@humanwhocodes/config-array@0.11.13: - resolution: {integrity: sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==} + /@humanwhocodes/config-array@0.11.14: + resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} engines: {node: '>=10.10.0'} + deprecated: Use @eslint/config-array instead dependencies: - '@humanwhocodes/object-schema': 2.0.1 - debug: 4.3.4 + '@humanwhocodes/object-schema': 2.0.3 + debug: 4.3.6 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -8212,8 +8287,9 @@ packages: engines: {node: '>=12.22'} dev: true - /@humanwhocodes/object-schema@2.0.1: - resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} + /@humanwhocodes/object-schema@2.0.3: + resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} + deprecated: Use @eslint/object-schema instead dev: true /@hutson/parse-repository-url@3.0.2: @@ -9317,10 +9393,6 @@ packages: '@types/unist': 2.0.10 dev: true - /@types/json-schema@7.0.15: - resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} - dev: true - /@types/mdast@3.0.15: resolution: {integrity: sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ==} dependencies: @@ -9363,10 +9435,6 @@ packages: resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} dev: true - /@types/semver@7.5.6: - resolution: {integrity: sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==} - dev: true - /@types/skmeans@0.11.7: resolution: {integrity: sha512-3fT48uRSRppOdQIlNCQKNNJRVaqzxkdCSTZM+NeHNxEpw6JejLLH78OHP54BxUHYEsa7pVsGn6uON552jwv9ZQ==} dev: true @@ -9416,127 +9484,125 @@ packages: resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} dev: true - /@typescript-eslint/eslint-plugin@6.13.2(@typescript-eslint/parser@6.13.2)(eslint@8.55.0)(typescript@5.5.4): - resolution: {integrity: sha512-3+9OGAWHhk4O1LlcwLBONbdXsAhLjyCFogJY/cWy2lxdVJ2JrcTF2pTGMaLl2AE7U1l31n8Py4a8bx5DLf/0dQ==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/eslint-plugin@8.2.0(@typescript-eslint/parser@8.2.0)(eslint@8.57.0)(typescript@5.5.4): + resolution: {integrity: sha512-02tJIs655em7fvt9gps/+4k4OsKULYGtLBPJfOsmOq1+3cdClYiF0+d6mHu6qDnTcg88wJBkcPLpQhq7FyDz0A==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha - eslint: ^7.0.0 || ^8.0.0 + '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 + eslint: ^8.57.0 || ^9.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 6.13.2(eslint@8.55.0)(typescript@5.5.4) - '@typescript-eslint/scope-manager': 6.13.2 - '@typescript-eslint/type-utils': 6.13.2(eslint@8.55.0)(typescript@5.5.4) - '@typescript-eslint/utils': 6.13.2(eslint@8.55.0)(typescript@5.5.4) - '@typescript-eslint/visitor-keys': 6.13.2 - debug: 4.3.4 - eslint: 8.55.0 + '@typescript-eslint/parser': 8.2.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/scope-manager': 8.2.0 + '@typescript-eslint/type-utils': 8.2.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/utils': 8.2.0(eslint@8.57.0)(typescript@5.5.4) + '@typescript-eslint/visitor-keys': 8.2.0 + eslint: 8.57.0 graphemer: 1.4.0 - ignore: 5.3.0 + ignore: 5.3.2 natural-compare: 1.4.0 - semver: 7.5.4 - ts-api-utils: 1.0.3(typescript@5.5.4) + ts-api-utils: 1.3.0(typescript@5.5.4) typescript: 5.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@6.13.2(eslint@8.55.0)(typescript@5.5.4): - resolution: {integrity: sha512-MUkcC+7Wt/QOGeVlM8aGGJZy1XV5YKjTpq9jK6r6/iLsGXhBVaGP5N0UYvFsu9BFlSpwY9kMretzdBH01rkRXg==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/parser@8.2.0(eslint@8.57.0)(typescript@5.5.4): + resolution: {integrity: sha512-j3Di+o0lHgPrb7FxL3fdEy6LJ/j2NE8u+AP/5cQ9SKb+JLH6V6UHDqJ+e0hXBkHP1wn1YDFjYCS9LBQsZDlDEg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 + eslint: ^8.57.0 || ^9.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 6.13.2 - '@typescript-eslint/types': 6.13.2 - '@typescript-eslint/typescript-estree': 6.13.2(typescript@5.5.4) - '@typescript-eslint/visitor-keys': 6.13.2 - debug: 4.3.4 - eslint: 8.55.0 + '@typescript-eslint/scope-manager': 8.2.0 + '@typescript-eslint/types': 8.2.0 + '@typescript-eslint/typescript-estree': 8.2.0(typescript@5.5.4) + '@typescript-eslint/visitor-keys': 8.2.0 + debug: 4.3.6 + eslint: 8.57.0 typescript: 5.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/scope-manager@6.13.2: - resolution: {integrity: sha512-CXQA0xo7z6x13FeDYCgBkjWzNqzBn8RXaE3QVQVIUm74fWJLkJkaHmHdKStrxQllGh6Q4eUGyNpMe0b1hMkXFA==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/scope-manager@8.2.0: + resolution: {integrity: sha512-OFn80B38yD6WwpoHU2Tz/fTz7CgFqInllBoC3WP+/jLbTb4gGPTy9HBSTsbDWkMdN55XlVU0mMDYAtgvlUspGw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} dependencies: - '@typescript-eslint/types': 6.13.2 - '@typescript-eslint/visitor-keys': 6.13.2 + '@typescript-eslint/types': 8.2.0 + '@typescript-eslint/visitor-keys': 8.2.0 dev: true - /@typescript-eslint/type-utils@6.13.2(eslint@8.55.0)(typescript@5.5.4): - resolution: {integrity: sha512-Qr6ssS1GFongzH2qfnWKkAQmMUyZSyOr0W54nZNU1MDfo+U4Mv3XveeLZzadc/yq8iYhQZHYT+eoXJqnACM1tw==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/type-utils@8.2.0(eslint@8.57.0)(typescript@5.5.4): + resolution: {integrity: sha512-g1CfXGFMQdT5S+0PSO0fvGXUaiSkl73U1n9LTK5aRAFnPlJ8dLKkXr4AaLFvPedW8lVDoMgLLE3JN98ZZfsj0w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 6.13.2(typescript@5.5.4) - '@typescript-eslint/utils': 6.13.2(eslint@8.55.0)(typescript@5.5.4) - debug: 4.3.4 - eslint: 8.55.0 - ts-api-utils: 1.0.3(typescript@5.5.4) + '@typescript-eslint/typescript-estree': 8.2.0(typescript@5.5.4) + '@typescript-eslint/utils': 8.2.0(eslint@8.57.0)(typescript@5.5.4) + debug: 4.3.6 + ts-api-utils: 1.3.0(typescript@5.5.4) typescript: 5.5.4 transitivePeerDependencies: + - eslint - supports-color dev: true - /@typescript-eslint/types@6.13.2: - resolution: {integrity: sha512-7sxbQ+EMRubQc3wTfTsycgYpSujyVbI1xw+3UMRUcrhSy+pN09y/lWzeKDbvhoqcRbHdc+APLs/PWYi/cisLPg==} - engines: {node: ^16.0.0 || >=18.0.0} - dev: true - /@typescript-eslint/types@7.18.0: resolution: {integrity: sha512-iZqi+Ds1y4EDYUtlOOC+aUmxnE9xS/yCigkjA7XpTKV6nCBd3Hp/PRGGmdwnfkV2ThMyYldP1wRpm/id99spTQ==} engines: {node: ^18.18.0 || >=20.0.0} dev: true - /@typescript-eslint/typescript-estree@6.13.2(typescript@5.5.4): - resolution: {integrity: sha512-SuD8YLQv6WHnOEtKv8D6HZUzOub855cfPnPMKvdM/Bh1plv1f7Q/0iFUDLKKlxHcEstQnaUU4QZskgQq74t+3w==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/types@8.2.0: + resolution: {integrity: sha512-6a9QSK396YqmiBKPkJtxsgZZZVjYQ6wQ/TlI0C65z7vInaETuC6HAHD98AGLC8DyIPqHytvNuS8bBVvNLKyqvQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dev: true + + /@typescript-eslint/typescript-estree@7.18.0(typescript@5.5.4): + resolution: {integrity: sha512-aP1v/BSPnnyhMHts8cf1qQ6Q1IFwwRvAQGRvBFkWlo3/lH29OXA3Pts+c10nxRxIBrDnoMqzhgdwVe5f2D6OzA==} + engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/types': 6.13.2 - '@typescript-eslint/visitor-keys': 6.13.2 - debug: 4.3.4 + '@typescript-eslint/types': 7.18.0 + '@typescript-eslint/visitor-keys': 7.18.0 + debug: 4.3.6 globby: 11.1.0 is-glob: 4.0.3 - semver: 7.5.4 - ts-api-utils: 1.0.3(typescript@5.5.4) + minimatch: 9.0.4 + semver: 7.6.3 + ts-api-utils: 1.3.0(typescript@5.5.4) typescript: 5.5.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/typescript-estree@7.18.0(typescript@5.5.4): - resolution: {integrity: sha512-aP1v/BSPnnyhMHts8cf1qQ6Q1IFwwRvAQGRvBFkWlo3/lH29OXA3Pts+c10nxRxIBrDnoMqzhgdwVe5f2D6OzA==} - engines: {node: ^18.18.0 || >=20.0.0} + /@typescript-eslint/typescript-estree@8.2.0(typescript@5.5.4): + resolution: {integrity: sha512-kiG4EDUT4dImplOsbh47B1QnNmXSoUqOjWDvCJw/o8LgfD0yr7k2uy54D5Wm0j4t71Ge1NkynGhpWdS0dEIAUA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' peerDependenciesMeta: typescript: optional: true dependencies: - '@typescript-eslint/types': 7.18.0 - '@typescript-eslint/visitor-keys': 7.18.0 - debug: 4.3.4 + '@typescript-eslint/types': 8.2.0 + '@typescript-eslint/visitor-keys': 8.2.0 + debug: 4.3.6 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.4 @@ -9547,33 +9613,22 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@6.13.2(eslint@8.55.0)(typescript@5.5.4): - resolution: {integrity: sha512-b9Ptq4eAZUym4idijCRzl61oPCwwREcfDI8xGk751Vhzig5fFZR9CyzDz4Sp/nxSLBYxUPyh4QdIDqWykFhNmQ==} - engines: {node: ^16.0.0 || >=18.0.0} + /@typescript-eslint/utils@8.2.0(eslint@8.57.0)(typescript@5.5.4): + resolution: {integrity: sha512-O46eaYKDlV3TvAVDNcoDzd5N550ckSe8G4phko++OCSC1dYIb9LTc3HDGYdWqWIAT5qDUKphO6sd9RrpIJJPfg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: - eslint: ^7.0.0 || ^8.0.0 - dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.55.0) - '@types/json-schema': 7.0.15 - '@types/semver': 7.5.6 - '@typescript-eslint/scope-manager': 6.13.2 - '@typescript-eslint/types': 6.13.2 - '@typescript-eslint/typescript-estree': 6.13.2(typescript@5.5.4) - eslint: 8.55.0 - semver: 7.5.4 + eslint: ^8.57.0 || ^9.0.0 + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) + '@typescript-eslint/scope-manager': 8.2.0 + '@typescript-eslint/types': 8.2.0 + '@typescript-eslint/typescript-estree': 8.2.0(typescript@5.5.4) + eslint: 8.57.0 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys@6.13.2: - resolution: {integrity: sha512-OGznFs0eAQXJsp+xSd6k/O1UbFi/K/L7WjqeRoFE7vadjAF9y0uppXhYNQNEqygjou782maGClOoZwPqF0Drlw==} - engines: {node: ^16.0.0 || >=18.0.0} - dependencies: - '@typescript-eslint/types': 6.13.2 - eslint-visitor-keys: 3.4.3 - dev: true - /@typescript-eslint/visitor-keys@7.18.0: resolution: {integrity: sha512-cDF0/Gf81QpY3xYyJKDV14Zwdmid5+uuENhjH2EqFaF0ni+yAyq/LzMaIJdhNJXZI7uLzwIlA+V7oWoyn6Curg==} engines: {node: ^18.18.0 || >=20.0.0} @@ -9582,6 +9637,14 @@ packages: eslint-visitor-keys: 3.4.3 dev: true + /@typescript-eslint/visitor-keys@8.2.0: + resolution: {integrity: sha512-sbgsPMW9yLvS7IhCi8IpuK1oBmtbWUNP+hBdwl/I9nzqVsszGnNGti5r9dUtF5RLivHUFFIdRvLiTsPhzSyJ3Q==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + dependencies: + '@typescript-eslint/types': 8.2.0 + eslint-visitor-keys: 3.4.3 + dev: true + /@ungap/structured-clone@1.2.0: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} dev: true @@ -9664,12 +9727,12 @@ packages: engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} dev: true - /acorn-jsx@5.3.2(acorn@8.11.2): + /acorn-jsx@5.3.2(acorn@8.12.1): resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - acorn: 8.11.2 + acorn: 8.12.1 dev: true /acorn@7.4.1: @@ -9684,6 +9747,12 @@ packages: hasBin: true dev: true + /acorn@8.12.1: + resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + /acorn@8.8.2: resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} engines: {node: '>=0.4.0'} @@ -9698,7 +9767,7 @@ packages: resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} engines: {node: '>= 14'} dependencies: - debug: 4.3.4 + debug: 4.3.6 transitivePeerDependencies: - supports-color dev: true @@ -11247,16 +11316,16 @@ packages: source-map: 0.6.1 dev: true - /eslint-config-prettier@9.1.0(eslint@8.55.0): + /eslint-config-prettier@9.1.0(eslint@8.57.0): resolution: {integrity: sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.55.0 + eslint: 8.57.0 dev: true - /eslint-plugin-prettier@5.0.1(eslint-config-prettier@9.1.0)(eslint@8.55.0)(prettier@3.3.3): + /eslint-plugin-prettier@5.0.1(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.3.3): resolution: {integrity: sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -11270,8 +11339,8 @@ packages: eslint-config-prettier: optional: true dependencies: - eslint: 8.55.0 - eslint-config-prettier: 9.1.0(eslint@8.55.0) + eslint: 8.57.0 + eslint-config-prettier: 9.1.0(eslint@8.57.0) prettier: 3.3.3 prettier-linter-helpers: 1.0.0 synckit: 0.8.6 @@ -11290,23 +11359,23 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint@8.55.0: - resolution: {integrity: sha512-iyUUAM0PCKj5QpwGfmCAG9XXbZCWsqP/eWAWrG/W0umvjuLRBECwSFdt+rCntju0xEH7teIABPwXpahftIaTdA==} + /eslint@8.57.0: + resolution: {integrity: sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.55.0) - '@eslint-community/regexpp': 4.10.0 + '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) + '@eslint-community/regexpp': 4.11.0 '@eslint/eslintrc': 2.1.4 - '@eslint/js': 8.55.0 - '@humanwhocodes/config-array': 0.11.13 + '@eslint/js': 8.57.0 + '@humanwhocodes/config-array': 0.11.14 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 '@ungap/structured-clone': 1.2.0 ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.6 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.2 @@ -11318,9 +11387,9 @@ packages: file-entry-cache: 6.0.1 find-up: 5.0.0 glob-parent: 6.0.2 - globals: 13.23.0 + globals: 13.24.0 graphemer: 1.4.0 - ignore: 5.3.0 + ignore: 5.3.2 imurmurhash: 0.1.4 is-glob: 4.0.3 is-path-inside: 3.0.3 @@ -11346,8 +11415,8 @@ packages: resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - acorn: 8.11.2 - acorn-jsx: 5.3.2(acorn@8.11.2) + acorn: 8.12.1 + acorn-jsx: 5.3.2(acorn@8.12.1) eslint-visitor-keys: 3.4.3 dev: true @@ -11951,8 +12020,8 @@ packages: engines: {node: '>=4'} dev: true - /globals@13.23.0: - resolution: {integrity: sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==} + /globals@13.24.0: + resolution: {integrity: sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==} engines: {node: '>=8'} dependencies: type-fest: 0.20.2 @@ -12208,7 +12277,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.1 - debug: 4.3.4 + debug: 4.3.6 transitivePeerDependencies: - supports-color dev: true @@ -12218,7 +12287,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.1 - debug: 4.3.4 + debug: 4.3.6 transitivePeerDependencies: - supports-color dev: true @@ -12276,6 +12345,11 @@ packages: engines: {node: '>= 4'} dev: true + /ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + dev: true + /import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} @@ -13739,7 +13813,7 @@ packages: resolution: {integrity: sha512-uD66tJj54JLYq0De10AhWycZWGQNUvDI55xPgk2sQM5kn1JYlhbCMTtEeT27+vAhW2FBQxLlOmS3pmA7/2z4aA==} dependencies: '@types/debug': 4.1.12 - debug: 4.3.4 + debug: 4.3.6 decode-named-character-reference: 1.0.2 micromark-core-commonmark: 1.1.0 micromark-factory-space: 1.1.0 @@ -15650,7 +15724,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.1 - debug: 4.3.4 + debug: 4.3.6 socks: 2.7.1 transitivePeerDependencies: - supports-color @@ -16194,15 +16268,6 @@ packages: resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==} dev: true - /ts-api-utils@1.0.3(typescript@5.5.4): - resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==} - engines: {node: '>=16.13.0'} - peerDependencies: - typescript: '>=4.2.0' - dependencies: - typescript: 5.5.4 - dev: true - /ts-api-utils@1.3.0(typescript@5.5.4): resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} engines: {node: '>=16'} @@ -16244,46 +16309,6 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - /tsup@8.0.1(postcss@8.4.40)(ts-node@9.1.1)(typescript@5.3.3): - resolution: {integrity: sha512-hvW7gUSG96j53ZTSlT4j/KL0q1Q2l6TqGBFc6/mu/L46IoNWqLLUzLRLP1R8Q7xrJTmkDxxDoojV5uCVs1sVOg==} - engines: {node: '>=18'} - hasBin: true - peerDependencies: - '@microsoft/api-extractor': ^7.36.0 - '@swc/core': ^1 - postcss: ^8.4.12 - typescript: '>=4.5.0' - peerDependenciesMeta: - '@microsoft/api-extractor': - optional: true - '@swc/core': - optional: true - postcss: - optional: true - typescript: - optional: true - dependencies: - bundle-require: 4.0.2(esbuild@0.19.11) - cac: 6.7.14 - chokidar: 3.5.3 - debug: 4.3.4 - esbuild: 0.19.11 - execa: 5.1.1 - globby: 11.1.0 - joycon: 3.1.1 - postcss: 8.4.40 - postcss-load-config: 4.0.2(postcss@8.4.40)(ts-node@9.1.1) - resolve-from: 5.0.0 - rollup: 4.9.0 - source-map: 0.8.0-beta.0 - sucrase: 3.34.0 - tree-kill: 1.2.2 - typescript: 5.3.3 - transitivePeerDependencies: - - supports-color - - ts-node - dev: true - /tsup@8.0.1(postcss@8.4.40)(ts-node@9.1.1)(typescript@5.5.4): resolution: {integrity: sha512-hvW7gUSG96j53ZTSlT4j/KL0q1Q2l6TqGBFc6/mu/L46IoNWqLLUzLRLP1R8Q7xrJTmkDxxDoojV5uCVs1sVOg==} engines: {node: '>=18'} @@ -16340,7 +16365,7 @@ packages: engines: {node: ^16.14.0 || >=18.0.0} dependencies: '@tufjs/models': 2.0.1 - debug: 4.3.4 + debug: 4.3.6 make-fetch-happen: 13.0.1 transitivePeerDependencies: - supports-color @@ -16436,12 +16461,6 @@ packages: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} dev: true - /typescript@5.3.3: - resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} - engines: {node: '>=14.17'} - hasBin: true - dev: true - /typescript@5.5.4: resolution: {integrity: sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==} engines: {node: '>=14.17'} diff --git a/tsconfig.shared.json b/tsconfig.shared.json index 56c4f8ea85..e7a99c086a 100644 --- a/tsconfig.shared.json +++ b/tsconfig.shared.json @@ -1,12 +1,19 @@ { + "include": ["${configDir}/index.?s"], // While we have a mix of TS and JS packages "compilerOptions": { + "allowJs": true, // Required to run tsc in legacy JS projects + "outDir": "${configDir}/dist", // Required to run tsc in legacy JS projects "target": "es2017", - "module": "node16", + "module": "esnext", "declaration": true, "esModuleInterop": true, "strict": true, - "moduleResolution": "node16", + "moduleResolution": "bundler", "importHelpers": true, - "skipLibCheck": true + "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "@turf/*": ["./packages/turf-*"] + } } } diff --git a/tsup.config.ts b/tsup.config.ts index 283f087732..4ade659d29 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -5,7 +5,6 @@ const baseOptions: Options = { dts: true, entry: ["index.?s"], // while we have a mix of TS and JS packages minify: false, - skipNodeModulesBundle: true, sourcemap: true, target: "es2017", tsconfig: "./tsconfig.json",