oddcelot
oddcelot
Aarktype
Created by oddcelot on 5/7/2025 in #questions
Equivalent of Object.values for unions
btw: the intention was to generate a JsonSchema, but it failed as the FontWeightAliasMap.infer defines undefined in runtime usage my workaround was to redeclare this
const FontWeightNames = type.enumerated(
"thin",
"hairline",
"extra-light",
"ultra-light",
"light",
"normal",
"regular",
"book",
"medium",
"semi-bold",
"demi-bold",
"bold",
"extra-bold",
"ultra-bold",
"black",
"heavy",
"extra-black",
"ultra-black"
);

export const FontWeight = type({
$type: "'fontWeight'",
$value: type("1 <= number <= 1000").or(FontWeightNames),
});
const FontWeightNames = type.enumerated(
"thin",
"hairline",
"extra-light",
"ultra-light",
"light",
"normal",
"regular",
"book",
"medium",
"semi-bold",
"demi-bold",
"bold",
"extra-bold",
"ultra-bold",
"black",
"heavy",
"extra-black",
"ultra-black"
);

export const FontWeight = type({
$type: "'fontWeight'",
$value: type("1 <= number <= 1000").or(FontWeightNames),
});
2 replies