cospired / i18n-iso-languages

i18n for ISO 639-1 language codes
MIT License
49 stars 29 forks source link

Return types in TypeScript declaration files are too narrow #29

Closed DanielSWolf closed 3 years ago

DanielSWolf commented 3 years ago

According to index.d.ts, the function getAlpha2Code always returns a string. According to the unit tests, it returns a string on success, undefined otherwise.

The type definition should be changed to read

export function getAlpha2Code(name: string, lang: string): string | undefined;

I suspect that the same is true for most of the functions.

e110c0 commented 3 years ago

MR would be welcome for this

DanielSWolf commented 3 years ago

I've created a PR.

e110c0 commented 3 years ago

Thank you. PR merged and will be in the next release.