Within my next.js application,
I have implemented an object with string keys and string values within a select box, as shown below:
export const HOURS: { [key: string]: string } = {
'00': '00',
'01': '01',
'02': '02',
'03': '03',
'04': '04',
'05': '05',
'06': '06',
'07': '07',
'08': '08',
'09': '09',
'10': '10',
'11': '11',
'12': '12',
'13': '13',
'14': '14',
'15': '15',
'16': '16',
'17': '17',
'18': '18',
'19': '19',
'20': '20',
'21': '21',
'22': '22',
'23': '23',
} as const
While testing locally, the object displays correctly as defined.
However, upon bundling and deploying the application, the keys are automatically converted to numbers, resulting in a different order for the select box ('00' becomes 0 and '01' becomes 1).
0: "00",
1: "01",
2: "02"
...
Is there a solution to maintain the original key declaration and preserve the desired order?
I have attempted specifying types { [key: string]: string }
as well as using as const
, but these methods have not been successful.