Skip to content

Commit 470eb93

Browse files
feat(country-flag-icons): type definition (DefinitelyTyped#46177)
* feat(country-flag-icons): type definition - definition files - tests https://www.npmjs.com/package/country-flag-icons https://gitlab.com/catamphetamine/country-flag-icons/-/blob/master/README.md Thanks! * Update types/country-flag-icons/index.d.ts Co-authored-by: Sheetal Nandi <[email protected]> Co-authored-by: Sheetal Nandi <[email protected]>
1 parent 048972a commit 470eb93

File tree

6 files changed

+48
-0
lines changed

6 files changed

+48
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function hasFlag(country: string): boolean;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { countries, hasFlag } from 'country-flag-icons';
2+
import getUnicodeFlagIcon from 'country-flag-icons/unicode';
3+
4+
hasFlag('US'); // $ExpectType boolean
5+
hasFlag('ZZ'); // $ExpectType boolean
6+
countries; // $ExpectType string[]
7+
countries.includes('US'); // $ExpectType boolean
8+
countries.includes('ZZ'); // $ExpectType boolean
9+
getUnicodeFlagIcon('US'); // $ExpectType string
10+
getUnicodeFlagIcon('ZZ'); // $ExpectType string
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Type definitions for country-flag-icons 1.2
2+
// Project: https://gitlab.com/catamphetamine/country-flag-icons#readme
3+
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+
export { default as hasFlag } from "./commonjs/hasFlag";
7+
export const countries: string[];
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"es6", "ES2017"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictFunctionTypes": true,
10+
"strictNullChecks": true,
11+
"baseUrl": "../",
12+
"typeRoots": [
13+
"../"
14+
],
15+
"types": [],
16+
"noEmit": true,
17+
"forceConsistentCasingInFileNames": true
18+
},
19+
"files": [
20+
"index.d.ts",
21+
"country-flag-icons-tests.ts"
22+
]
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "extends": "dtslint/dt.json" }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Creates Unicode flag from a two-letter ISO country code.
3+
* https://stackoverflow.com/questions/24050671/how-to-put-japan-flag-character-in-a-string
4+
* @param country — A two-letter ISO country code (case-insensitive).
5+
*/
6+
export default function getCountryFlag(country: string): string;

0 commit comments

Comments
 (0)