Open
Description
const EnvSchema = v.object({
STAGE: v.pipe(
v.nullish(v.picklist(['alpha', 'prod'])),
v.transform(input => {
switch (input) {
case 'alpha': return 'alpha';
case 'prod': return 'production';
default: return 'development';
}
}),
),
});
type EnvInput = v.InferInput<typeof EnvSchema>;
type EnvOutput = v.InferOutput<typeof EnvSchema>;
EnvSchema
parses { STAGE?: "alpha" | "prod" | undefined | null }
and transforms it to { STAGE: "alpha" | "production" | "development" }
So I expected the EnvOutput
type to be { STAGE: "alpha" | "production" | "development" }
, but it's { STAGE?: "alpha" | "production" | "development" | undefined }
This is the same for nullish
and optional
, but works as expected with nullable
and undefinedable
.