After reading this response, I decided to create some union types from a string[] in order to return a list of valid type values. However, instead of that, the type ends up accepting any string value.
const arrayDays = Array.from(Array(32).keys(), (num) =>
num.toString().padStart(2, '0'),
)
const listDays = [...arrayDays.splice(1)] as const
type Day = (typeof listDays)[number]
I initially expected that the type Day would be something like
type Days = '01' | '02' .... | '30' | '31'
, but its actual type is string
https://i.stack.imgur.com/iNrPl.png
As a result, when using the Day type in a variable, it accepts any string value.
const day1: Day = '' //does not show an error
const day2: Dat = 'y' //does not show an error