mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
The typings didn't match the library. * `lookup` takes a `string` (or a `number` if you so choose): https://github.com/davglass/zipcodes/blob/master/lib/index.js#L13 * `distance` takes two `string`s, not `ZipCode` objects: https://github.com/davglass/zipcodes/blob/master/lib/index.js#L56 * similarly, `radius` takes a string rather than a `ZipCode` object, and always returns an array (of `string`s or `ZipCode` objects): https://github.com/davglass/zipcodes/blob/master/lib/index.js#L80 * Many return values are optional, with `null` or `undefined` returned for an invalid input.
37 lines
914 B
TypeScript
37 lines
914 B
TypeScript
import * as ZipCodes from 'zipcodes';
|
|
|
|
const zipA: ZipCodes.ZipCode = {
|
|
zip: '90210',
|
|
latitude: 34.088808,
|
|
longitude: -118.406125,
|
|
city: 'Beverly Hills',
|
|
state: 'CA',
|
|
country: 'US'
|
|
};
|
|
|
|
const zipB: ZipCodes.ZipCode = {
|
|
zip: '95015',
|
|
latitude: 37.323,
|
|
longitude: -122.0527,
|
|
city: 'Cupertino',
|
|
state: 'CA',
|
|
country: 'US'
|
|
};
|
|
|
|
ZipCodes.lookup(zipA.zip); // $ExpectType ZipCode | undefined
|
|
|
|
ZipCodes.lookupByName('Cupertino', 'CA'); // $ExpectType ZipCode[]
|
|
|
|
ZipCodes.lookupByState('CA'); // $ExpectType ZipCode[]
|
|
|
|
ZipCodes.distance(zipA.zip, zipB.zip); // $ExpectType number | null
|
|
|
|
ZipCodes.radius(zipA.zip, 1, true); // $ExpectType ZipCode[] | string[]
|
|
ZipCodes.radius(zipA.zip, 1, false); // $ExpectType ZipCode[] | string[]
|
|
|
|
ZipCodes.toMiles(3); // $ExpectType number
|
|
|
|
ZipCodes.toKilometers(3); // $ExpectType number
|
|
|
|
ZipCodes.lookupByCoords(37.323, -122.0527); // $ExpectType string | null
|