UNPKG

osm-api

Version:

πŸ—ΊοΈπŸŒ Javascript/Typescript wrapper around the OpenStreetMap API

61 lines (60 loc) β€’ 1.93 kB
declare global { namespace OsmApi { /** * use this interface to get additional typesafety, see the documentation * on {@link Key} for more info. */ interface Keys { } } } /** * By default, this library defines {@link Tags} to be `Record<string, string>`. This * means that you don't get any typesafety for OSM keys/tags. * * There are two methods to make this more strict: * * 1. enable TypeScript's `noPropertyAccessFromIndexSignature` along with eslint's `dot-notation`. * This is not perfect, but it will force you to use `tags[KEY]` instead of `tags.key` which * makes the hardcoded keys more visible. * * 2. Declare a string union for every permitted osm key. For example: * ```ts * declare global { * namespace OsmApi { * interface Keys { * keys: 'amenity' | 'highway'; * } * } * } * export {}; * ``` * * Regardless of what method you use, it also makes sense to enable TypeScript's * `noUncheckedIndexedAccess` option. */ export type Key = OsmApi.Keys extends { keys: string; } ? OsmApi.Keys["keys"] : string; export type Tags = OsmApi.Keys extends { keys: string; } ? Partial<Record<Key, string>> : Record<string, string>; export type BBox = readonly [ minLng: number, minLat: number, maxLng: number, maxLat: number ]; /** shared by various APIs that support filtering */ export interface BasicFilters { /** Limits the number of items returned @default 100 */ limit?: number; /** Find items by the user. You cannot supply both `user` and `display_name` */ user?: number; /** Find items by the user. You cannot supply both `user` and `display_name` */ display_name?: string; /** The beginning of a date range to search in for an item */ from?: string; /** The end of a date range to search in for an item */ to?: string; }