From 593b226eac8371d96da85562cb303797b8fe400e Mon Sep 17 00:00:00 2001 From: Chad Burt Date: Wed, 20 Nov 2019 12:34:45 -0800 Subject: [PATCH] [@types/geobuf] Add typings for geobuf project (#40532) * Add types for geobuf https://github.com/mapbox/geobuf * Remove patch version from header --- types/geobuf/geobuf-tests.ts | 14 ++++++++++++++ types/geobuf/index.d.ts | 9 +++++++++ types/geobuf/tsconfig.json | 23 +++++++++++++++++++++++ types/geobuf/tslint.json | 1 + 4 files changed, 47 insertions(+) create mode 100644 types/geobuf/geobuf-tests.ts create mode 100644 types/geobuf/index.d.ts create mode 100644 types/geobuf/tsconfig.json create mode 100644 types/geobuf/tslint.json diff --git a/types/geobuf/geobuf-tests.ts b/types/geobuf/geobuf-tests.ts new file mode 100644 index 0000000000..3ca2b0c91d --- /dev/null +++ b/types/geobuf/geobuf-tests.ts @@ -0,0 +1,14 @@ +import * as geobuf from 'geobuf'; +import { GeoJSON } from 'geojson'; +import Pbf = require('pbf'); + +geobuf.decode(new Pbf(Uint8Array.from([]))); // $ExpectType GeoJSON +const geojson: GeoJSON = { + type: 'Feature', + properties: {}, + geometry: { + type: 'Point', + coordinates: [-127, 19] + } +}; +geobuf.encode(geojson, new Pbf()); // $ExpectType Uint8Array diff --git a/types/geobuf/index.d.ts b/types/geobuf/index.d.ts new file mode 100644 index 0000000000..98d0ea4055 --- /dev/null +++ b/types/geobuf/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for geobuf 3.0 +// Project: https://github.com/mapbox/geobuf +// Definitions by: Chad Burt +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +import Pbf = require('pbf'); +import { GeoJSON } from 'geojson'; + +export function decode(pbf: Pbf): GeoJSON; +export function encode(obj: GeoJSON, pbf: Pbf): Uint8Array; diff --git a/types/geobuf/tsconfig.json b/types/geobuf/tsconfig.json new file mode 100644 index 0000000000..2a94e75656 --- /dev/null +++ b/types/geobuf/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "geobuf-tests.ts" + ] +} diff --git a/types/geobuf/tslint.json b/types/geobuf/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/geobuf/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }