mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
fixed types for mapbox/wellknown (#41424)
* fixed types for mapbox/wellknown * added author, added null return type and test * added null to $ExpectType return type * fixed tests
This commit is contained in:
committed by
Eli Barzilay
parent
e760626f33
commit
c5fd5466d6
34
types/wellknown/index.d.ts
vendored
34
types/wellknown/index.d.ts
vendored
@@ -1,7 +1,35 @@
|
||||
// Type definitions for wellknown 0.5
|
||||
// Project: https://github.com/mapbox/wellknown#readme
|
||||
// Definitions by: Yair Tawil <https://github.com/yairtawil>
|
||||
// Definitions by: Davide Scalzo <https://github.com/davodesign84>
|
||||
// Yair Tawil <https://github.com/yairtawil>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function parse(input: string): {};
|
||||
export function stringify(gj: {}): string;
|
||||
export type GeoJSONPosition = [number, number] | [number, number, number];
|
||||
|
||||
export interface Geometry<T, C> {
|
||||
type: T;
|
||||
coordinates: C;
|
||||
}
|
||||
|
||||
export type GeoJSONPoint = Geometry<"Point", GeoJSONPosition>;
|
||||
export type GeoJSONMultiPoint = Geometry<"MultiPoint", GeoJSONPosition[]>;
|
||||
|
||||
export type GeoJSONLineString = Geometry<"LineString", GeoJSONPosition[]>;
|
||||
|
||||
export type GeoJSONMultiLineString = Geometry<"MultiLineString", GeoJSONPosition[][]>;
|
||||
|
||||
export type GeoJSONPolygon = Geometry<"Polygon", GeoJSONPosition[][]>;
|
||||
|
||||
export type GeoJSONMultiPolygon = Geometry<"MultiPolygon", GeoJSONPosition[][][]>;
|
||||
|
||||
export type GeoJSONGeometry =
|
||||
| GeoJSONPoint
|
||||
| GeoJSONMultiPoint
|
||||
| GeoJSONLineString
|
||||
| GeoJSONMultiLineString
|
||||
| GeoJSONPolygon
|
||||
| GeoJSONMultiPolygon
|
||||
| null;
|
||||
|
||||
export function parse(input: string): GeoJSONGeometry;
|
||||
export function stringify(gj: GeoJSONGeometry): string;
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
import * as wellknown from 'wellknown';
|
||||
wellknown.parse("POINT(1 2)");
|
||||
const geoJson: {} = {
|
||||
|
||||
wellknown.parse("POINT(1 2)"); // $ExpectType GeoJSONGeometry
|
||||
|
||||
const geoJson: wellknown.GeoJSONGeometry = {
|
||||
coordinates: [1, 2],
|
||||
type: "Point"
|
||||
};
|
||||
wellknown.stringify(geoJson);
|
||||
|
||||
wellknown.stringify(geoJson); // $ExpectType string
|
||||
|
||||
Reference in New Issue
Block a user