Skip to content

Commit

Permalink
[countries-and-timezones] Add typings for v2.0 (#39052)
Browse files Browse the repository at this point in the history
* [countries-and-timezones] Add typings for v2.0

* Fix path mapping

* Fix copy pasta mistake

* Remove v1 typings
  • Loading branch information
pokonski authored and andrewbranch committed Oct 18, 2019
1 parent 221b638 commit 18653ea
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
@@ -1,6 +1,8 @@
import * as lib from 'countries-and-timezones';

lib.getCountry('IT');
lib.getTimezone('Europe/Warsaw');
lib.getAllCountries();
lib.getAllTimezones();
lib.getCountriesForTimezone('Europe/London');
lib.getCountryForTimezone('Europe/London');
lib.getTimezonesForCountry('GB');
25 changes: 14 additions & 11 deletions types/countries-and-timezones/index.d.ts
@@ -1,25 +1,28 @@
// Type definitions for countries-and-timezones 1.0
// Type definitions for countries-and-timezones 2.0
// Project: https://github.com/manuelmhtr/countries-and-timezones#readme
// Definitions by: David Bird <https://github.com/zero51>
// Piotr Okoński <https://github.com/pokonski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

export interface Country {
id: string;
name: string;
timezones: string[];
timezones: ReadonlyArray<string>;
}

export interface Timezone {
name: string;
utcOffset: number;
offsetStr: string;
countries: string[];
utcOffsetStr: string;
dstOffset: number;
dstOffsetStr: string;
aliasOf: string | null;
country: string | null;
}

export function getAllCountries(): {[key: string]: Country};

export function getAllTimezones(): {[key: string]: Timezone};

export function getCountriesForTimezone(timezoneId: string): Country[];

export function getTimezonesForCountry(countryId: string): Timezone[];
export function getCountry(id: string): Country;
export function getTimezone(name: string): Timezone;
export function getAllCountries(): Country[];
export function getAllTimezones(): Timezone[];
export function getCountryForTimezone(name: string): Country;
export function getTimezonesForCountry(id: string): Timezone[];

0 comments on commit 18653ea

Please sign in to comment.