We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IndexesOf
ItemsOf
This is a way to have typed indexes of a tuple, useful when you have types deriving of a const value
const
definition:
type ItemOf<T extends readonly any[]> = T[number] type IndexesOf<T extends readonly any[]> = Exclude<Partial<T>['length'], T['length']>
use case:
const WEEK_DAYS = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] as const type WeekDayName = ItemsOf<typeof WEEK_DAYS> type WeekDay = IndexesOf<typeof WEEK_DAYS> const getDayName = (day: WeekDay): WeekDayName => WEEK_DAYS[day]
The text was updated successfully, but these errors were encountered:
Related: #658
I'm not sure which names are best ItemsOf or ArrayValue.
ArrayValue
Sorry, something went wrong.
@sindresorhus ArrayValue and ArrayIndex looks good
ArrayIndex
Successfully merging a pull request may close this issue.
This is a way to have typed indexes of a tuple, useful when you have types deriving of a
const
valuedefinition:
use case:
The text was updated successfully, but these errors were encountered: