Skip to content

Commit e175989

Browse files
authored
🤖 Merge PR DefinitelyTyped#74168 [geojson-precision] create definitions by @k-yle
1 parent becfc1c commit e175989

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

types/geojson-precision/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { LineString, Point } from "geojson";
2+
import parse from "geojson-precision";
3+
4+
const point: Point = { type: "Point", coordinates: [12.45, 56.78] };
5+
let line: LineString = { type: "LineString", coordinates: [] };
6+
7+
let trimmed = parse(point, 3);
8+
// $ExpectType Point
9+
trimmed;
10+
11+
line = parse(line, 4);
12+
line = parse.parse(line, 4);
13+
14+
parse.parse.parse.parse.parse; // this is silly, but technically possible

types/geojson-precision/index.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as GeoJSON from "geojson";
2+
3+
interface Parse {
4+
/**
5+
* Remove meaningless precision from your GeoJSON.
6+
*
7+
* @param coordinatePrecision A positive integer. If your specified precision value
8+
* is greater than the precision of the input geometry, the output precision
9+
* will be the same as the input. For example, if your input coordinates are
10+
* `[10.0, 20.0]`, and you specify a precision of `5`, the output will be the
11+
* same as the input.
12+
*
13+
* @param extrasPrecision A positive integer specifying extra coordinate precision
14+
* for things like the `z` value when the coordinate is
15+
* `[longitude, latitude, elevation]`.
16+
*/
17+
<T extends GeoJSON.Geometry>(
18+
geometry: T,
19+
coordinatePrecision: number,
20+
extrasPrecision?: number,
21+
): T;
22+
parse: Parse;
23+
}
24+
25+
declare const parse: Parse;
26+
export = parse;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"name": "@types/geojson-precision",
4+
"version": "1.0.9999",
5+
"projects": [
6+
"https://github.com/jczaplew/geojson-precision"
7+
],
8+
"dependencies": {
9+
"@types/geojson": "*"
10+
},
11+
"devDependencies": {
12+
"@types/geojson-precision": "workspace:."
13+
},
14+
"owners": [
15+
{
16+
"name": "Kyle Hensel",
17+
"githubUsername": "k-yle"
18+
}
19+
]
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"module": "node16",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"types": [],
12+
"noEmit": true,
13+
"forceConsistentCasingInFileNames": true
14+
},
15+
"files": [
16+
"index.d.ts",
17+
"geojson-precision-tests.ts"
18+
]
19+
}

0 commit comments

Comments
 (0)