Merge pull request #27927 from dobesv/patch-5

Fix typings for zipcodes
This commit is contained in:
Ron Buckton 2018-08-08 13:27:36 -07:00 committed by GitHub
commit 2e01482f92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -1,6 +1,6 @@
// Type definitions for zipcodes 6.0
// Type definitions for zipcodes 6.1
// Project: https://github.com/davglass/zipcodes#readme
// Definitions by: Brayden Lopez <https://github.com/headdetect>
// Definitions by: Brayden Lopez <https://github.com/headdetect>, Dobes Vandermeer <https://github.com/dobesv>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace ZipCodes;
@ -14,18 +14,18 @@ export interface ZipCode {
country: string;
}
export function lookup(zip: any): ZipCode;
export function lookup(zip: string|number): ZipCode | undefined;
export function lookupByName(city: string, state: string): ZipCode[];
export function lookupByState(state: string): ZipCode[];
export function distance(zipA: ZipCode, zipB: ZipCode): number;
export function distance(zipA: string|number, zipB: string|number): number | null;
export function radius(zip: ZipCode, miles: number, full: boolean): string | ZipCode[];
export function radius(zip: string|number, miles: number, full: boolean): string[] | ZipCode[];
export function toMiles(kilos: number): number;
export function toKilometers(miles: number): number;
export function lookupByCoords(lat: number, lon: number): ZipCode;
export function lookupByCoords(lat: number, lon: number): string | null;

View File

@ -18,19 +18,19 @@ const zipB: ZipCodes.ZipCode = {
country: 'US'
};
ZipCodes.lookup(zipA); // $ExpectType ZipCode
ZipCodes.lookup(zipA.zip); // $ExpectType ZipCode | undefined
ZipCodes.lookupByName('Cupertino', 'CA'); // $ExpectType ZipCode[]
ZipCodes.lookupByState('CA'); // $ExpectType ZipCode[]
ZipCodes.distance(zipA, zipB); // $ExpectType number
ZipCodes.distance(zipA.zip, zipB.zip); // $ExpectType number | null
ZipCodes.radius(zipA, 1, true); // $ExpectType string | ZipCode[]
ZipCodes.radius(zipA, 1, false); // $ExpectType string | ZipCode[]
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 ZipCode
ZipCodes.lookupByCoords(37.323, -122.0527); // $ExpectType string | null