-
-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
wontfixThis will not be worked onThis will not be worked on
Description
This is a great QoL addition that I've been using a lot from ts-dotenv, but the implementation details of this library is so different that another approach is better.
In ts-dotenv you specify an array that are cast as const as so:
LOG_LEVEL: {
type: [
'fatal' as const,
'error' as const,
'warn' as const,
'info' as const,
'debug' as const,
'trace' as const
],
default: 'info'
},which gives you the type
'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace'It would be amazing if we could conditionally do this for choices. Here is an example of how it can be done:
function stringLiteralArray<T extends string>(a: T[]) {
return a;
}
const fruits = stringLiteralArray(["Apple", "Orange", "Pear"]);
type Fruits = typeof fruits[number]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
wontfixThis will not be worked onThis will not be worked on