diff --git a/dist/index.d.ts b/dist/index.d.ts index 38ab1e2..ff6c56f 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -67,3 +67,14 @@ declare type TCountryToString = Record declare type TStringToCountry = Record declare type TLanguages = Record declare type TLanguageToString = Record + +declare const getCountryCode: (countryName: string) => TCountryCode | false; +declare const getCountryData: (iso2: TCountryCode) => ICountryData; +declare const getCountryDataList: () => ICountryData[]; +declare const getEmojiFlag: (countryCode: TCountryCode) => string; + +declare const continents: TContinents +declare const countries: TCountries +declare const languages: TLanguages + +export { continents, countries, getCountryCode, getCountryData, getCountryDataList, getEmojiFlag, languages }; diff --git a/packages/scripts/tasks/generateTypings.ts b/packages/scripts/tasks/generateTypings.ts index 7a24137..12ebdb5 100644 --- a/packages/scripts/tasks/generateTypings.ts +++ b/packages/scripts/tasks/generateTypings.ts @@ -10,12 +10,26 @@ export const generateTypings = (): void => { const current = fs.readFileSync('../countries/src/types.ts', { encoding: 'utf-8', }) - const typings = current - .replace(/export/g, 'declare') - .replace(/import .* from '.*'\n/g, '') - .replace('keyof typeof continents', "'" + Object.keys(continents).join("' | '") + "'") - .replace('keyof typeof countries', "'" + Object.keys(countries).join("' | '") + "'") - .replace('keyof typeof languages', "'" + Object.keys(languages).join("' | '") + "'") + const typings = + current + .replace(/export/g, 'declare') + .replace(/import .* from '.*'\n/g, '') + .replace('keyof typeof continents', "'" + Object.keys(continents).join("' | '") + "'") + .replace('keyof typeof countries', "'" + Object.keys(countries).join("' | '") + "'") + .replace('keyof typeof languages', "'" + Object.keys(languages).join("' | '") + "'") + + [ + '', + 'declare const getCountryCode: (countryName: string) => TCountryCode | false;', + 'declare const getCountryData: (iso2: TCountryCode) => ICountryData;', + 'declare const getCountryDataList: () => ICountryData[];', + 'declare const getEmojiFlag: (countryCode: TCountryCode) => string;', + '', + 'declare const continents: TContinents', + 'declare const countries: TCountries', + 'declare const languages: TLanguages', + '', + 'export { continents, countries, getCountryCode, getCountryData, getCountryDataList, getEmojiFlag, languages };', + ].join('\n') saveTextFile('index.d.ts', typings.trim()) }