Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[countries-and-timezones] Add typings for v2.0 #39052

Merged
merged 4 commits into from Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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[];