Skip to content

Commit 31d8c45

Browse files
authored
Merge pull request #416 from morellodev/better-ts-support
added stricter typing for country prop
2 parents 16a5cb1 + 098f812 commit 31d8c45

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/countryCodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,6 @@ const countryCodes = [
252252
'GB-WLS',
253253
'GB-ZET',
254254
'US-CA',
255-
];
255+
] as const;
256256

257257
export default countryCodes;

src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React, { FC, HTMLAttributes } from 'react';
22
import countryCodes from './countryCodes';
33

4+
export type CountryCode = typeof countryCodes[number];
5+
46
export interface Props extends HTMLAttributes<HTMLImageElement> {
5-
country?: string;
7+
country?: CountryCode | Omit<string, CountryCode>;
68
role?: string;
79
size?: number;
810
alt?: string;

0 commit comments

Comments
 (0)