Skip to content

Commit e8e7d53

Browse files
committed
Improve colorKeys type
1 parent f707a45 commit e8e7d53

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

examples/SignUp/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class SignUp extends React.Component<Props, State> {
229229
resetButtonDisabled
230230
} = this.state;
231231

232-
const Color: { [index: string]: string } = {
232+
const Color = {
233233
Red: t('Red'),
234234
Orange: t('Orange'),
235235
Yellow: t('Yellow'),
@@ -238,7 +238,7 @@ class SignUp extends React.Component<Props, State> {
238238
Indigo: t('Indigo'),
239239
Violet: t('Violet')
240240
};
241-
const colorKeys = Object.keys(Color);
241+
const colorKeys = Object.keys(Color) as (keyof typeof Color)[];
242242

243243
return (
244244
<>

examples/WizardForm/Color.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export enum Color {
88
Violet = 'Violet'
99
}
1010

11-
export const colorKeys = Object.keys(Color);
11+
export const colorKeys = Object.keys(Color) as (keyof typeof Color)[];

examples/WizardForm/WizardFormStep3.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function WizardFormStep3(props: Props) {
4545
Select a color...
4646
</option>
4747
{colorKeys.map(colorKey => (
48-
<option value={Color[colorKey as keyof typeof Color]} key={colorKey}>
48+
<option value={Color[colorKey]} key={colorKey}>
4949
{colorKey}
5050
</option>
5151
))}

0 commit comments

Comments
 (0)