Add typing for topojson-server (#34145)

This commit is contained in:
Russell Porter
2019-03-25 18:00:23 +01:00
committed by timolinn
parent b446b9a64f
commit 17e11f7ef0
7 changed files with 58 additions and 17 deletions

13
types/topojson-server/index.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
// Type definitions for topojson-server 3.0
// Project: https://github.com/topojson/topojson-server
// Definitions by: Ricardo Mello <https://github.com/ricardo-mello>
// Zhutian Chen <https://github.com/chenzhutian>
// denisname <https://github.com/denisname>
// Russell Porter <https://github.com/russellporter>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.5
import * as GeoJSON from "geojson";
import * as TopoJSON from "topojson-specification";
export function topology(objects: {[k: string]: GeoJSON.GeoJsonObject}, quantization?: number): TopoJSON.Topology;

View File

@@ -0,0 +1,19 @@
// Tests for: https://github.com/topojson/topojson-server
import * as topojson from "topojson-server";
let topo: TopoJSON.Topology;
const aPoint: GeoJSON.Point = { type: "Point", coordinates: [30, 10] };
const aPolygon: GeoJSON.Polygon = {
type: "Polygon",
coordinates: [[[30, 10], [40, 40], [20, 40], [30, 10]]]
};
const objects = {
aPoint,
aPolygon
};
topo = topojson.topology(objects);
topo = topojson.topology(objects, 1e4);

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"topojson-server-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -15,7 +15,7 @@ export as namespace topojson;
// TopoJSON Server
// ---------------------------------------------------------------
export function topology(objects: {[k: string]: GeoJSON.GeoJsonObject}, quantization?: number): TopoJSON.Topology;
export * from 'topojson-server';
// ---------------------------------------------------------------
// TopoJSON Simplify

View File

@@ -1,14 +0,0 @@
// Tests for: https://github.com/topojson/topojson-server
let topo: TopoJSON.Topology;
const aPoint: GeoJSON.Point = {type: "Point", coordinates: [30, 10]};
const aPolygon: GeoJSON.Polygon = {type: "Polygon", coordinates: [[[30, 10], [40, 40], [20, 40], [30, 10]]]};
const objects = {
aPoint,
aPolygon,
};
topo = topojson.topology(objects);
topo = topojson.topology(objects, 1e4);

View File

@@ -20,7 +20,6 @@
"files": [
"index.d.ts",
"topojson-tests.ts",
"test/atlas-tests.ts",
"test/server-tests.ts"
"test/atlas-tests.ts"
]
}